From 44b4e71c05dfa87618e78b85b8f76c23845e6957 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Thu, 26 Jan 2017 14:21:35 +0100 Subject: [PATCH] Manual importing almost done. Needs fixing for mapping movies. --- .../Series/FetchMovieListModule.cs | 19 +++++++++-- .../CouchPotato/CouchPotatoParser.cs | 6 ++-- src/UI/AddMovies/List/AddFromListView.js | 33 ++++++++++++++++--- .../List/AddFromListViewTemplate.hbs | 5 ++- src/UI/Cells/MovieListTitleCell.js | 7 ++++ src/UI/Cells/MovieListTitleTemplate.hbs | 1 + 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 src/UI/Cells/MovieListTitleCell.js create mode 100644 src/UI/Cells/MovieListTitleTemplate.hbs diff --git a/src/NzbDrone.Api/Series/FetchMovieListModule.cs b/src/NzbDrone.Api/Series/FetchMovieListModule.cs index a6ec92f76..52475d0cb 100644 --- a/src/NzbDrone.Api/Series/FetchMovieListModule.cs +++ b/src/NzbDrone.Api/Series/FetchMovieListModule.cs @@ -11,11 +11,13 @@ namespace NzbDrone.Api.Movie public class FetchMovieListModule : NzbDroneRestModule { private readonly IFetchNetImport _fetchNetImport; + private readonly ISearchForNewMovie _movieSearch; - public FetchMovieListModule(IFetchNetImport netImport) + public FetchMovieListModule(IFetchNetImport netImport, ISearchForNewMovie movieSearch) : base("/netimport/movies") { _fetchNetImport = netImport; + _movieSearch = movieSearch; Get["/"] = x => Search(); } @@ -23,7 +25,20 @@ namespace NzbDrone.Api.Movie private Response Search() { var results = _fetchNetImport.FetchAndFilter((int) Request.Query.listId, false); - return MapToResource(results).AsResponse(); + + List realResults = new List(); + + foreach (var movie in results) + { + var mapped = _movieSearch.MapMovieToTmdbMovie(movie); + + if (mapped != null) + { + realResults.Add(mapped); + } + } + + return MapToResource(realResults).AsResponse(); } diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs index 424e5cc71..48b7b76d7 100644 --- a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs @@ -56,6 +56,8 @@ namespace NzbDrone.Core.NetImport.CouchPotato foreach (var item in responseData) { + int tmdbid = item.info.tmdb_id ?? 0; + // if there are no releases at all the movie wasn't found on CP, so return movies if (!item.releases.Any() && item.type == "movie") { @@ -63,7 +65,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato { Title = item.title, ImdbId = item.info.imdb, - TmdbId = item.info.tmdb_id + TmdbId = tmdbid }); } else @@ -77,7 +79,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato { Title = item.title, ImdbId = item.info.imdb, - TmdbId = item.info.tmdb_id, + TmdbId = tmdbid, Monitored = false }); } diff --git a/src/UI/AddMovies/List/AddFromListView.js b/src/UI/AddMovies/List/AddFromListView.js index 292d02665..05d60dcad 100644 --- a/src/UI/AddMovies/List/AddFromListView.js +++ b/src/UI/AddMovies/List/AddFromListView.js @@ -12,7 +12,8 @@ var ErrorView = require('../ErrorView'); var LoadingView = require('../../Shared/LoadingView'); var AppLayout = require('../../AppLayout'); var InCinemasCell = require('../../Cells/InCinemasCell'); -var MovieTitleCell = require('../../Cells/MovieTitleCell'); +var MovieTitleCell = require('../../Cells/MovieListTitleCell'); +var SelectAllCell = require('../../Cells/SelectAllCell'); var TemplatedCell = require('../../Cells/TemplatedCell'); var ProfileCell = require('../../Cells/ProfileCell'); var MovieLinksCell = require('../../Cells/MovieLinksCell'); @@ -20,6 +21,7 @@ var MovieActionCell = require('../../Cells/MovieActionCell'); var MovieStatusCell = require('../../Cells/MovieStatusCell'); var MovieDownloadStatusCell = require('../../Cells/MovieDownloadStatusCell'); var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell'); +var MoviesCollection = require('../../Movies/MoviesCollection'); var SchemaModal = require('../../Settings/NetImport/Add/NetImportSchemaModal'); @@ -37,6 +39,12 @@ module.exports = Marionette.Layout.extend({ }, columns : [ + { + name : '', + cell : SelectAllCell, + headerCell : 'select-all', + sortable : false + }, { name : 'title', label : 'Title', @@ -60,7 +68,8 @@ module.exports = Marionette.Layout.extend({ events : { 'click .x-load-more' : '_onLoadMore', "change .x-list-selection" : "_listSelected", - "click .x-fetch-list" : "_fetchList" + "click .x-fetch-list" : "_fetchList", + "click .x-import-selected" : "_importSelected" }, initialize : function(options) { @@ -173,6 +182,21 @@ module.exports = Marionette.Layout.extend({ this.render(); }, + _importSelected : function() { + var selected = this.importGrid.getSelectedModels(); + console.log(selected); + _.each(selected, function(elem){ + elem.save(); + }) + /*for (m in selected) { + debugger; + m.save() + MoviesCollection.add(m); + }*/ + + //MoviesCollection.save(); + }, + _clearResults : function() { if (!this.isExisting) { @@ -186,11 +210,12 @@ module.exports = Marionette.Layout.extend({ if (this.collection.length === 0) { this.fetchResult.show(new NotFoundView({ term : "" })); } else { - this.fetchResult.show(new Backgrid.Grid({ + this.importGrid = new Backgrid.Grid({ collection : this.collection, columns : this.columns, className : 'table table-hover' - })); + }); + this.fetchResult.show(this.importGrid); } }, diff --git a/src/UI/AddMovies/List/AddFromListViewTemplate.hbs b/src/UI/AddMovies/List/AddFromListViewTemplate.hbs index fcf4e2611..cad2b19bc 100644 --- a/src/UI/AddMovies/List/AddFromListViewTemplate.hbs +++ b/src/UI/AddMovies/List/AddFromListViewTemplate.hbs @@ -5,9 +5,12 @@
{{> ListSelectionPartial lists}}
-
+
+
+ +
diff --git a/src/UI/Cells/MovieListTitleCell.js b/src/UI/Cells/MovieListTitleCell.js new file mode 100644 index 000000000..6d9142131 --- /dev/null +++ b/src/UI/Cells/MovieListTitleCell.js @@ -0,0 +1,7 @@ +var TemplatedCell = require('./TemplatedCell'); + +module.exports = TemplatedCell.extend({ + className : 'series-title-cell', + template : 'Cells/MovieListTitleTemplate', + +}); diff --git a/src/UI/Cells/MovieListTitleTemplate.hbs b/src/UI/Cells/MovieListTitleTemplate.hbs new file mode 100644 index 000000000..6c4bb964b --- /dev/null +++ b/src/UI/Cells/MovieListTitleTemplate.hbs @@ -0,0 +1 @@ +{{title}}