mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-06-16 01:11:48 +02:00
add torrent sale expires time, and show in video info view
This commit is contained in:
3
config/env/torrents.js
vendored
3
config/env/torrents.js
vendored
@@ -61,7 +61,8 @@ module.exports = {
|
||||
{name: 'U3/D.5', desc: 'Upload * 3, Download * 0.5'},
|
||||
{name: 'U3/D.8', desc: 'Upload * 3, Download * 0.8'},
|
||||
{name: 'U3/D1', desc: 'Upload * 3, Download * 1'}
|
||||
]
|
||||
],
|
||||
expires: {size: 1024 * 1024 * 1024, time: 60 * 60 * 1000}
|
||||
},
|
||||
torrentSalesValue: {
|
||||
global: undefined,
|
||||
|
||||
@@ -128,6 +128,8 @@
|
||||
ATTRIBUTE_TAGS: '视频属性(标签)',
|
||||
VIDEO_NFO: '视频 NFO',
|
||||
VIDEO_SIZE: '视频文件大小',
|
||||
VIDEO_SALE_INFO: '视频促销信息',
|
||||
SALE_EXPIRES_TIME: '过期',
|
||||
UPLOAD_SUBTITLE: '上传字幕文件',
|
||||
SUBTITLE_LIST: '字幕列表',
|
||||
SUBTITLE_RULES: {
|
||||
|
||||
@@ -128,6 +128,8 @@
|
||||
ATTRIBUTE_TAGS: 'Video Attribute (tags)',
|
||||
VIDEO_NFO: 'Video NFO',
|
||||
VIDEO_SIZE: 'Video Size',
|
||||
VIDEO_SALE_INFO: 'Video Sale Info',
|
||||
SALE_EXPIRES_TIME: 'expires',
|
||||
UPLOAD_SUBTITLE: 'Upload Subtitle file',
|
||||
SUBTITLE_LIST: 'Subtitle list',
|
||||
SUBTITLE_RULES: {
|
||||
|
||||
@@ -37,4 +37,38 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
angular.module('core')
|
||||
.filter('unlife', unlife);
|
||||
|
||||
unlife.$inject = ['moment'];
|
||||
|
||||
function unlife(moment) {
|
||||
return function (expires) {
|
||||
var d = moment(expires).diff(moment(), 'days');
|
||||
var h = moment(expires).diff(moment(), 'hours');
|
||||
var m = moment(expires).diff(moment(), 'minutes');
|
||||
var s = moment(expires).diff(moment(), 'seconds');
|
||||
|
||||
if (!expires) {
|
||||
d = 0;
|
||||
h = 0;
|
||||
m = 0;
|
||||
s = 0;
|
||||
}
|
||||
|
||||
if (d > 0) {
|
||||
h = h - d * 24;
|
||||
return d + 'd' + h + 'h';
|
||||
} else if (h > 0) {
|
||||
m = m - h * 60;
|
||||
return h + 'h' + m + 'm';
|
||||
} else if (m > 0) {
|
||||
s = s - m * 60;
|
||||
return m + 'm' + s + 's';
|
||||
} else {
|
||||
return s + 's';
|
||||
}
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -315,6 +315,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.label-sale {
|
||||
color: #0366d6;
|
||||
background-color: #f1f8ff;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: #f00;
|
||||
}
|
||||
&:active {
|
||||
color: #0366d6;
|
||||
}
|
||||
&.used {
|
||||
background-color: #c9e4ff !important;
|
||||
}
|
||||
}
|
||||
|
||||
.inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@@ -291,6 +291,17 @@
|
||||
<dt class="h-line">{{ 'VIDEO_SIZE' | translate}}:</dt>
|
||||
<dd class="h-line">{{vm.torrentLocalInfo.torrent_size | bytes:2}}</dd>
|
||||
|
||||
<dt class="h-line">{{ 'VIDEO_SALE_INFO' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<span class="label"
|
||||
ng-class="{'label-default': !vm.torrentLocalInfo.isSaling, 'label-success': vm.torrentLocalInfo.isSaling}">
|
||||
{{vm.torrentLocalInfo.torrent_sale_status}}
|
||||
</span>
|
||||
<span ng-if="vm.torrentLocalInfo.isSaling">
|
||||
[{{ 'SALE_EXPIRES_TIME' | translate}}: {{vm.torrentLocalInfo.torrent_sale_expires | unlife}}]
|
||||
</span>
|
||||
</dd>
|
||||
|
||||
<dt class="h-line">{{ 'ATTRIBUTE_TAGS' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<div class="list-all-tags">
|
||||
|
||||
@@ -307,7 +307,9 @@ exports.setSaleType = function (req, res) {
|
||||
var torrent = req.torrent;
|
||||
|
||||
if (req.params.saleType) {
|
||||
var gbit = Math.ceil(torrent.torrent_size / config.meanTorrentConfig.torrentSalesType.expires.size);
|
||||
torrent.torrent_sale_status = req.params.saleType;
|
||||
torrent.torrent_sale_expires = Date.now() + gbit * config.meanTorrentConfig.torrentSalesType.expires.time;
|
||||
|
||||
torrent.save(function (err) {
|
||||
if (err) {
|
||||
|
||||
@@ -146,6 +146,9 @@ var TorrentSchema = new Schema({
|
||||
default: 'U1/D1',
|
||||
trim: true
|
||||
},
|
||||
torrent_sale_expires: {
|
||||
type: Date
|
||||
},
|
||||
torrent_recommended: {
|
||||
type: Number,
|
||||
default: 0
|
||||
@@ -170,6 +173,27 @@ var TorrentSchema = new Schema({
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* overwrite toJSON
|
||||
*/
|
||||
TorrentSchema.methods.toJSON = function (options) {
|
||||
var document = this.toObject(options);
|
||||
document.isSaling = false;
|
||||
|
||||
if (this.torrent_sale_expires > Date.now()) {
|
||||
document.isSaling = true;
|
||||
}
|
||||
|
||||
if (!document.isSaling) {
|
||||
document.torrent_sale_status = 'U1/D1';
|
||||
}
|
||||
if(document.torrent_sale_status === 'U1/D1'){
|
||||
document.isSaling=false;
|
||||
}
|
||||
|
||||
return document;
|
||||
};
|
||||
|
||||
TorrentSchema.index({user: -1, createdat: -1});
|
||||
TorrentSchema.index({info_hash: -1, createdat: -1});
|
||||
TorrentSchema.index({torrent_tmdb_id: -1, createdat: -1});
|
||||
|
||||
Reference in New Issue
Block a user