diff --git a/routes/channel.js b/routes/channel.js index afb7f64..385acb3 100644 --- a/routes/channel.js +++ b/routes/channel.js @@ -54,9 +54,9 @@ router.get('/:id', function(req, res, next) { channel_info = row; }); - 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 = ? " + db.each("SELECT i.id as id, i.title as title, i.duration as second, i.year as year" + + " FROM metadata_items i, media_items t " + + " WHERE i.id = t.metadata_item_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/movie.js b/routes/movie.js index 5d3bc25..b72c0b4 100644 --- a/routes/movie.js +++ b/routes/movie.js @@ -1,6 +1,22 @@ var express = require('express'); var router = express.Router(); +function humanFileSize(bytes, si) { + var thresh = si ? 1000 : 1024; + if(Math.abs(bytes) < thresh) { + return bytes + ' B'; + } + var units = si + ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] + : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; + var u = -1; + do { + bytes /= thresh; + ++u; + } while(Math.abs(bytes) >= thresh && u < units.length - 1); + return bytes.toFixed(1)+' '+units[u]; +} + /* GET home page. */ router.get('/:id', function(req, res, next) { @@ -22,6 +38,8 @@ router.get('/:id', function(req, res, next) { var filename = tab2[tab2.length -1]; ligne.filename = filename; + ligne.size = humanFileSize(ligne.size,true); + row.file.push(ligne); },function(){ res.render('movie', { title: 'Détail vidéo',movie: row }); diff --git a/views/channel.jade b/views/channel.jade index ef9f6ad..0ddfbb6 100644 --- a/views/channel.jade +++ b/views/channel.jade @@ -7,39 +7,20 @@ block content thead tr th Nom - if(channel.type == 2) - th Série - th Saison & Episode th Durée th Année - th Taille tbody each video, i in videos tr td a(href="/movie/#{video.id}")= video.title - if(channel.type == 2) - td - if(typeof video.info_meta !== 'undefined' && typeof video.info_meta.show !== 'undefined') - | #{video.info_meta.show} - td - if(typeof video.season_episode !== 'undefined') - | #{video.season_episode} td= video.duree td= video.year - td= video.size script. $(document).ready(function() { $('#example').DataTable({ "language": { "url": "//cdn.datatables.net/plug-ins/1.10.8/i18n/French.json" - }/*, - "columnDefs": [ - { "targets": 2, - "searchable": false, - "orderable": false, - } - ]*/ - //"dom": '<"toolbar">frtip' + } }); }); diff --git a/views/movie.jade b/views/movie.jade index d1453e3..42daa1f 100644 --- a/views/movie.jade +++ b/views/movie.jade @@ -7,7 +7,9 @@ block content p= movie.rating label Télécharger + br each file, i in movie.file + file.size a(href="/file/#{file.id}/#{file.filename}")= file.filename br