mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-06 20:21:01 +01:00
@@ -2,7 +2,7 @@
|
||||
|
||||
var querystring = require('querystring');
|
||||
|
||||
/**
|
||||
/**
|
||||
* binaryToHex
|
||||
* @param str
|
||||
*/
|
||||
@@ -32,3 +32,18 @@ module.exports.hexToBinary = function (str) {
|
||||
module.exports.querystringParse = function (q) {
|
||||
return querystring.parse(q, null, null, {decodeURIComponent: unescape});
|
||||
};
|
||||
|
||||
/**
|
||||
* fileSizeFormat
|
||||
* @param bytes
|
||||
* @param precision
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports.fileSizeFormat = function (bytes, precision) {
|
||||
if (bytes === 0 || isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
|
||||
if (typeof precision === 'undefined') precision = 1;
|
||||
//var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
|
||||
var units = ['b', 'K', 'M', 'G', 'T', 'P'],
|
||||
number = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + units[number];
|
||||
};
|
||||
|
||||
@@ -287,6 +287,7 @@
|
||||
TORRENT_FILENAME: 'Torrent Filename',
|
||||
ATTRIBUTE_TAGS: 'Video Attribute (tags)',
|
||||
VIDEO_NFO: 'Video NFO',
|
||||
ALL_FILES_LIST: 'Files List',
|
||||
VIDEO_SIZE: 'Video Size',
|
||||
VIDEO_SALE_INFO: 'Video Sale Info',
|
||||
SALE_EXPIRES_TIME: 'expires',
|
||||
|
||||
@@ -287,6 +287,7 @@
|
||||
TORRENT_FILENAME: '种子文件名',
|
||||
ATTRIBUTE_TAGS: '视频属性(标签)',
|
||||
VIDEO_NFO: '视频 NFO',
|
||||
ALL_FILES_LIST: '文件清单',
|
||||
VIDEO_SIZE: '视频文件大小',
|
||||
VIDEO_SALE_INFO: '视频促销信息',
|
||||
SALE_EXPIRES_TIME: '过期',
|
||||
|
||||
@@ -1363,6 +1363,32 @@ body {
|
||||
background-color: #fff !important;
|
||||
}
|
||||
|
||||
.all-files {
|
||||
json-tree {
|
||||
json-node.expandable {
|
||||
&::before {
|
||||
content: '\25b6';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: -2px;
|
||||
font-size: 10px;
|
||||
transition: transform .1s ease;
|
||||
}
|
||||
}
|
||||
.branch-preview {
|
||||
max-width: 80%;
|
||||
height: 2em;
|
||||
}
|
||||
.branch-value {
|
||||
background-color: #fff;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
border: solid 1px #ccc;
|
||||
border-radius: 4px;
|
||||
padding: 2px 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.subtitle-list {
|
||||
padding-left: 0;
|
||||
.glyphicon {
|
||||
|
||||
@@ -608,6 +608,15 @@
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<dt class="h-line">{{ 'ALL_FILES_LIST' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<div class="row">
|
||||
<div class="col-md-10 all-files">
|
||||
<json-tree root-name="vm.torrentLocalInfo._all_files.length + ' files'" object="vm.torrentLocalInfo._all_files"></json-tree>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt class="h-line" ng-if="vm.torrentLocalInfo.torrent_nfo.length>0">{{ 'VIDEO_NFO' | translate}}:</dt>
|
||||
<dd class="h-line" ng-if="vm.torrentLocalInfo.torrent_nfo.length>0">
|
||||
<div class="row">
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
var path = require('path'),
|
||||
config = require(path.resolve('./config/config')),
|
||||
mongoose = require('mongoose'),
|
||||
common = require(path.resolve('./config/lib/common')),
|
||||
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller')),
|
||||
multer = require('multer'),
|
||||
moment = require('moment'),
|
||||
@@ -1838,7 +1839,29 @@ exports.torrentByID = function (req, res, next, id) {
|
||||
}
|
||||
};
|
||||
|
||||
async.waterfall([findTorrents, findOtherTorrents], function (err, torrent) {
|
||||
var writeAllFiles = function (torrent, callback) {
|
||||
var filePath = config.uploads.torrent.file.dest + torrent.torrent_filename;
|
||||
nt.read(filePath, function (err, torrent_data) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
var mdata = torrent_data.metadata;
|
||||
|
||||
if (mdata.info.files) {
|
||||
mdata.info.files.forEach(function (f) {
|
||||
torrent._all_files.push(f.path.join('/') + ', ' + common.fileSizeFormat(f.length, 2));
|
||||
});
|
||||
} else {
|
||||
torrent._all_files.push(mdata.info.name + ', ' + common.fileSizeFormat(mdata.info.length, 2));
|
||||
}
|
||||
|
||||
callback(null, torrent);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
async.waterfall([findTorrents, findOtherTorrents, writeAllFiles], function (err, torrent) {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else {
|
||||
|
||||
@@ -183,7 +183,7 @@ var TorrentSchema = new Schema({
|
||||
_thumbs: [ThumbSchema],
|
||||
_ratings: [RatingSchema],
|
||||
_other_torrents: [],
|
||||
|
||||
_all_files: [],
|
||||
//resource info
|
||||
resource_detail_info: Object,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user