diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js
index 6b9864e7..88696e36 100644
--- a/modules/core/client/app/trans-string-en.js
+++ b/modules/core/client/app/trans-string-en.js
@@ -104,8 +104,8 @@
ENTER_TMDB_ID: 'Please enter theMovieDB id [find id on themofiedb.org]',
LOAD_TMDB_INFO: 'Load info',
TMDB_ID: 'TMDB ID',
- TMDB_ID_OK: 'MDB ID is ok! Get info successfully',
- TMDB_ID_ERROR: 'MDB ID is error! Get info failed',
+ TMDB_ID_OK: 'TMDB ID is ok! Get info successfully',
+ TMDB_ID_ERROR: 'TMDB ID is error! Get info failed',
TMDB_ID_REQUIRED: 'Please enter TMDB ID',
TMDB_MOVIE_INFO: 'The movie info from TMDB',
TMDB_IS_LOADING: 'Loading the movie info, please wait...',
diff --git a/modules/torrents/client/config/torrents.client.routes.js b/modules/torrents/client/config/torrents.client.routes.js
index eddba17a..8318d436 100644
--- a/modules/torrents/client/config/torrents.client.routes.js
+++ b/modules/torrents/client/config/torrents.client.routes.js
@@ -15,11 +15,11 @@
template: ''
})
.state('torrents.movie', {
- url: '/torrents/movie',
+ url: '/movie',
templateUrl: '/modules/torrents/client/views/movie-list.client.view.html'
})
.state('torrents.uploads', {
- url: '/torrents/uploads',
+ url: '/uploads',
templateUrl: '/modules/torrents/client/views/uploads-torrents.client.view.html'
});
}
diff --git a/modules/torrents/client/controllers/torrents.client.controller.js b/modules/torrents/client/controllers/torrents.client.controller.js
index f12aa2ab..5c3c2b36 100644
--- a/modules/torrents/client/controllers/torrents.client.controller.js
+++ b/modules/torrents/client/controllers/torrents.client.controller.js
@@ -209,10 +209,10 @@
});
}
}, function (err) {
- Notification.error({
- message: err.data.message,
- title: ' ' + $translate.instant('TORRENT_DOWNLOAD_ERROR')
- });
+ //Notification.error({
+ // message: 'ERROR',
+ // title: ' ' + $translate.instant('TORRENT_DOWNLOAD_ERROR')
+ //});
});
};
}
diff --git a/modules/torrents/client/controllers/uploads.client.controller.js b/modules/torrents/client/controllers/uploads.client.controller.js
index ba9e1d4d..37cb7c30 100644
--- a/modules/torrents/client/controllers/uploads.client.controller.js
+++ b/modules/torrents/client/controllers/uploads.client.controller.js
@@ -183,7 +183,7 @@
var torrent = new TorrentsService({
info_hash: vm.torrentInfo.info_hash,
- torrent_filename: vm.tFile.name,
+ torrent_filename: vm.torrentInfo.filename,
torrent_tmdb_id: vm.tmdb_id,
torrent_imdb_id: vm.movieinfo.imdb_id,
torrent_title: vm.movieinfo.title,
diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js
index b7a9cd0c..93fafad9 100644
--- a/modules/torrents/server/controllers/torrents.server.controller.js
+++ b/modules/torrents/server/controllers/torrents.server.controller.js
@@ -12,6 +12,7 @@ var path = require('path'),
Torrent = mongoose.model('Torrent'),
fs = require('fs'),
nt = require('nt'),
+ benc = require('bncode'),
validator = require('validator'),
tmdb = require('moviedb')(config.meanTorrentConfig.tmdbConfig.key);
@@ -99,6 +100,7 @@ exports.upload = function (req, res) {
function checkAnnounce() {
return new Promise(function (resolve, reject) {
+ console.log(req.file.filename);
var newfile = config.uploads.torrent.file.dest + req.file.filename;
nt.read(newfile, function (err, torrent) {
var message = '';
@@ -107,8 +109,8 @@ exports.upload = function (req, res) {
message = 'Read torrent file faild';
reject(message);
} else {
- if (!config.announce.open_tracker) {
- if (torrent.metadata.announce !== config.announce.url) {
+ if (!config.meanTorrentConfig.announce.open_tracker) {
+ if (torrent.metadata.announce !== config.meanTorrentConfig.announce.url) {
console.log(torrent.metadata.announce);
message = 'ANNOUNCE_URL_ERROR';
@@ -124,6 +126,7 @@ exports.upload = function (req, res) {
}
torrentinfo = torrent.metadata;
torrentinfo.info_hash = torrent.infoHash();
+ torrentinfo.filename = req.file.filename;
resolve();
}
});
@@ -174,33 +177,67 @@ exports.upload = function (req, res) {
* @param res
*/
exports.download = function (req, res) {
+ var torrent_data = null;
var filePath = config.uploads.torrent.file.dest + req.torrent.torrent_filename;
var stat = fs.statSync(filePath);
fs.exists(filePath, function (exists) {
if (exists) {
- var options = {
- root: path.join(__dirname, '../../../../'),
- headers: {
- 'Content-Type': 'application/x-bittorrent',
- 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
- 'Content-Length': stat.size
- }
- };
- res.sendFile(filePath, options);
+ getTorrentFileData(filePath)
+ .then(function () {
+ //var options = {
+ // root: path.join(__dirname, '../../../../'),
+ // headers: {
+ // 'Content-Type': 'application/x-bittorrent',
+ // 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
+ // 'Content-Length': stat.size
+ // }
+ //};
+ //res.sendFile(filePath, options);
- //res.writeHead(200, {
- // 'Content-Type': 'application/octet-stream',
- // 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
- // 'Content-Length': stat.size
- //});
- //fs.createReadStream(filePath).pipe(res);
+ res.set('Content-Type', 'application/x-bittorrent');
+ res.set('Content-Disposition', 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename);
+ res.set('Content-Length', stat.size);
+
+ console.log(torrent_data);
+ res.send(benc.encode(torrent_data));
+
+ //res.writeHead(200, {
+ // 'Content-Type': 'application/octet-stream',
+ // 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
+ // 'Content-Length': stat.size
+ //});
+ //fs.createReadStream(filePath).pipe(res);
+ })
+ .catch(function (err) {
+ res.status(422).send(err);
+ });
} else {
res.status(401).send({
message: 'FILE_DOES_NOT_EXISTS'
});
}
});
+
+ function getTorrentFileData(file) {
+ return new Promise(function (resolve, reject) {
+ nt.read(file, function (err, torrent) {
+ var message = '';
+
+ if (err) {
+ message = 'Read torrent file faild';
+ reject(message);
+ } else {
+ if (!config.meanTorrentConfig.announce.open_tracker) {
+ var announce = config.meanTorrentConfig.announce.url + '/' + req.user.passkey;
+ torrent.metadata.announce = announce;
+ }
+ torrent_data = torrent.metadata;
+ resolve();
+ }
+ });
+ });
+ }
};
/**