diff --git a/modules/core/client/app/config.js b/modules/core/client/app/config.js index 9d186f69..a970aefe 100644 --- a/modules/core/client/app/config.js +++ b/modules/core/client/app/config.js @@ -24,7 +24,7 @@ // Angular-ui-notification configuration angular.module('ui-notification').config(function(NotificationProvider) { NotificationProvider.setOptions({ - delay: 2000, + delay: 4000, startTop: 20, startRight: 10, verticalSpacing: 20, diff --git a/modules/core/client/app/trans-string-cn.js b/modules/core/client/app/trans-string-cn.js index 983fcd20..2a632dc2 100644 --- a/modules/core/client/app/trans-string-cn.js +++ b/modules/core/client/app/trans-string-cn.js @@ -61,7 +61,14 @@ SELECT_TORRENT_FILE: '请选择种子文件', SELECT_FILE: '选择文件', - DO_UPLOADS: '上传' + DO_UPLOADS: '上传', + ENTER_TMDB_ID: '请输入TMDB_ID', + LOAD_TMDB_INFO: '检索信息', + TMDB_ID: 'TMDB ID', + TMDB_ID_OK: 'MDB ID 正确,检索信息成功!', + TMDB_ID_ERROR: 'MDB ID 错误,检索信息失败!', + TMDB_ID_REQUIRED: '请输入 TMDB ID', + TMDB_MOVIE_INFO: 'TMDB 视频信息' }; // ************************************************** diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index c63bb39d..be86e82d 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -61,7 +61,14 @@ SELECT_TORRENT_FILE: 'Please select the torrent file', SELECT_FILE: 'Select file', - DO_UPLOADS: 'Uploads' + DO_UPLOADS: 'Uploads', + 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_REQUIRED: 'Please enter TMDB ID', + TMDB_MOVIE_INFO: 'The movie info from TMDB' }; // ************************************************** diff --git a/modules/torrents/client/controllers/uploads.client.controller.js b/modules/torrents/client/controllers/uploads.client.controller.js index 328f2bf2..dcd8af37 100644 --- a/modules/torrents/client/controllers/uploads.client.controller.js +++ b/modules/torrents/client/controllers/uploads.client.controller.js @@ -5,15 +5,19 @@ .module('torrents') .controller('TorrentsUploadsController', TorrentsUploadsController); - TorrentsUploadsController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'AnnounceConfig', 'Upload', 'Notification']; + TorrentsUploadsController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'AnnounceConfig', 'Upload', 'Notification', + 'TorrentsService']; - function TorrentsUploadsController($scope, $state, $translate, $timeout, Authentication, AnnounceConfig, Upload, Notification) { + function TorrentsUploadsController($scope, $state, $translate, $timeout, Authentication, AnnounceConfig, Upload, Notification, + TorrentsService) { var vm = this; vm.announce = AnnounceConfig.announce; vm.rule_items = []; + vm.movieinfoarray = []; vm.user = Authentication.user; vm.progress = 0; vm.successfully = undefined; + vm.tmbd_info_ok = undefined; for (var i = 0; i < $translate.instant('UPLOADS_RULES_COUNT'); i++) { vm.rule_items[i] = i; @@ -24,15 +28,15 @@ $state.go('authentication.signin'); } - //begin upload + //******************** begin upload torrent file ********************* vm.upload = function (dataUrl) { console.log(dataUrl); - if(dataUrl===null){ + if (dataUrl === null || dataUrl === undefined) { vm.fileSelected = false; // Show success message - Notification.success({ - message: ' ' + $translate.instant('TORRENTS_NO_FILE_SELECTED') + Notification.info({ + message: ' ' + $translate.instant('TORRENTS_NO_FILE_SELECTED') }); return; } @@ -54,7 +58,6 @@ }); }; - // Called after the user has successfully uploaded a new picture function onSuccessItem(response) { vm.fileSelected = false; vm.successfully = true; @@ -64,7 +67,6 @@ }); } - // Called after the user has failed to upload a new picture function onErrorItem(response) { vm.fileSelected = false; vm.successfully = false; @@ -75,5 +77,52 @@ title: ' ' + $translate.instant('TORRENTS_UPLOAD_FAILED') }); } + + //************** begin get tmdb info *********************************** + vm.onTextClick = function ($event) { + $event.target.select(); + }; + + vm.getInfo = function (tmdbid) { + console.log(tmdbid); + if (tmdbid === null || tmdbid === undefined) { + Notification.info({ + message: ' ' + $translate.instant('TMDB_ID_REQUIRED') + }); + angular.element('#tmdbid').focus(); + return; + } + + TorrentsService.getTMDBInfo({ + tmdbid: tmdbid, + language: 'zh' + }, function (res) { + vm.tmbd_info_ok = true; + Notification.success({ + message: ' ' + $translate.instant('TMDB_ID_OK') + }); + + console.log(res); + vm.movieinfo = res; + for (var item in res) { + if(item[0]!=='$' && item!=='toJSON') { + var value = res[item]; + var nv = { + key: item, + value: value + }; + vm.movieinfoarray.push(nv); + } + } + console.log(vm.movieinfo); + }, function (err) { + vm.tmbd_info_ok = false; + Notification.error({ + message: ' ' + $translate.instant('TMDB_ID_ERROR') + }); + angular.element('#tmdbid').focus(); + }); + }; + } }()); diff --git a/modules/torrents/client/services/torrents.client.service.js b/modules/torrents/client/services/torrents.client.service.js index fd0c0f1d..70d22fea 100644 --- a/modules/torrents/client/services/torrents.client.service.js +++ b/modules/torrents/client/services/torrents.client.service.js @@ -12,6 +12,14 @@ var Torrents = $resource('/api/torrents', {}, { update: { method: 'POST' + }, + getTMDBInfo: { + method: 'GET', + url: '/api/movieinfo/:tmdbid/:language', + params: { + tmdbid: '@tmdbid', + language: '@language' + } } }); diff --git a/modules/torrents/client/views/uploads-torrents.client.view.html b/modules/torrents/client/views/uploads-torrents.client.view.html index ca2bdafd..82fae85f 100644 --- a/modules/torrents/client/views/uploads-torrents.client.view.html +++ b/modules/torrents/client/views/uploads-torrents.client.view.html @@ -12,7 +12,7 @@
-
+
@@ -21,6 +21,7 @@
-
+
-
+
+
+
+ +
+
+ + +
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+ +
+
+
+
{{d.key}}:
+
{{d.value}}
+
+
+
+
\ No newline at end of file diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js index e21592da..3f708e60 100644 --- a/modules/torrents/server/controllers/torrents.server.controller.js +++ b/modules/torrents/server/controllers/torrents.server.controller.js @@ -18,10 +18,14 @@ var path = require('path'), */ exports.movieinfo = function (req, res) { console.log('------- API: movieinfo --------------------'); + console.log(req.params); - tmdb.movieInfo({id: 263115, language: 'zh'}, function (err, info) { + tmdb.movieInfo({ + id: req.params.tmdbid, + language: req.params.language + }, function (err, info) { if (err) { - console.log(err); + res.status(900).send(err); } else { res.json(info); } diff --git a/modules/torrents/server/routes/torrents.server.routes.js b/modules/torrents/server/routes/torrents.server.routes.js index 247b9db1..c0ada019 100644 --- a/modules/torrents/server/routes/torrents.server.routes.js +++ b/modules/torrents/server/routes/torrents.server.routes.js @@ -7,7 +7,7 @@ var torrents = require('../controllers/torrents.server.controller'); module.exports = function (app) { // Articles collection routes - app.route('/api/movieinfo') + app.route('/api/movieinfo/:tmdbid/:language') .get(torrents.movieinfo); app.route('/api/torrents/upload')