Manual importing almost done. Needs fixing for mapping movies.

Leonardo Galli 8 years ago
parent e2c2bdb65b
commit 44b4e71c05

@ -11,11 +11,13 @@ namespace NzbDrone.Api.Movie
public class FetchMovieListModule : NzbDroneRestModule<MovieResource>
{
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<Core.Tv.Movie> realResults = new List<Core.Tv.Movie>();
foreach (var movie in results)
{
var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
if (mapped != null)
{
realResults.Add(mapped);
}
}
return MapToResource(realResults).AsResponse();
}

@ -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
});
}

@ -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);
}
},

@ -5,9 +5,12 @@
<div class="col-sm-8">
{{> ListSelectionPartial lists}}
</div>
<div class="col-sm-3">
<div class="col-sm-1">
<button class="btn x-fetch-list">Fetch List</button>
</div>
<div class="col-sm-2">
<button class="btn btn-success x-import-selected">Import Selected</button>
</div>
</div>
</div>
<div class="row">

@ -0,0 +1,7 @@
var TemplatedCell = require('./TemplatedCell');
module.exports = TemplatedCell.extend({
className : 'series-title-cell',
template : 'Cells/MovieListTitleTemplate',
});

@ -0,0 +1 @@
<a href="{{imdbUrl}}">{{title}}</a>
Loading…
Cancel
Save