From 512c8bbbb79873d991d54eee3b1eeece916fbe61 Mon Sep 17 00:00:00 2001 From: WEBER Antoine Date: Thu, 24 Sep 2015 00:02:59 +0200 Subject: [PATCH] se baser sur les id de file --- routes/channel.js | 8 ++++---- routes/file.js | 2 +- routes/movie.js | 13 +++++++++++-- views/movie.jade | 5 +++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/routes/channel.js b/routes/channel.js index 25889c8..eb60afd 100644 --- a/routes/channel.js +++ b/routes/channel.js @@ -53,10 +53,10 @@ router.get('/:id', function(req, res, next) { + " FROM library_sections WHERE id = ? ORDER BY name ASC",req.params.id, function(err, row) { channel_info = row; }); -console.log("test2") - db.each("SELECT i.id as id, i.title as title, t.hints as hints, p.file as file, i.duration as second, t.size as size, i.year as year" - + " FROM media_items t, metadata_items i, media_parts p " - + " WHERE p.media_item_id=t.id AND t.metadata_item_id = i.id AND i.title != '' AND t.library_section_id = ? " + + db.each("SELECT i.id as id, i.title as title, t.hints as hints i.duration as second, t.size as size, i.year as year" + + " FROM media_items t, metadata_items i " + + " WHERE t.metadata_item_id = i.id AND i.title != '' AND t.library_section_id = ? " + " ORDER BY i.title ASC",req.params.id, function(err, row) { //découpage des hints diff --git a/routes/file.js b/routes/file.js index b5ecc9a..dfab0f8 100644 --- a/routes/file.js +++ b/routes/file.js @@ -14,7 +14,7 @@ router.get('/:id/:filename', function (req, res, next) { //} //stmt.finalize(); - db.get("SELECT file FROM media_parts WHERE media_item_id = ?",req.params.id, function(err, row) { + db.get("SELECT file FROM media_parts WHERE id = ?",req.params.id, function(err, row) { var options = { //root: /*__dirname +*/ '/public/', diff --git a/routes/movie.js b/routes/movie.js index 749713d..3d79a3b 100644 --- a/routes/movie.js +++ b/routes/movie.js @@ -14,9 +14,18 @@ router.get('/:id', function(req, res, next) { row.tags_genre = row.tags_genre.split('|'); row.tags_star = row.tags_star.split('|'); row.rating = Math.round(row.rating,2); - data = row; + row.file = []; - res.render('movie', { title: 'Détail vidéo',movie: data }); + db.each("SELECT id,file,size,hash,duration FROM media_parts where media_item_id IN (SELECT id FROM media_items WHERE metadata_items_id = ? )",req.params.id, function(error, ligne) { + var tab = ligne.file.split('/'); + var tab2 = tab[tab.length -1].split('\\'); + var filename = tab2[tab2.length -1]; + ligne.filename = filename; + + row.file.push(ligne); + },function(){ + res.render('movie', { title: 'Détail vidéo',movie: row }); + }); }); diff --git a/views/movie.jade b/views/movie.jade index a90dcd6..d1453e3 100644 --- a/views/movie.jade +++ b/views/movie.jade @@ -7,8 +7,9 @@ block content p= movie.rating label Télécharger - a(href="/file/#{movie.id}/#{movie.title}")= movie.title - br + each file, i in movie.file + a(href="/file/#{file.id}/#{file.filename}")= file.filename + br label Résumé p= movie.summary