mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-29 05:16:34 +02:00
Added discovery tab based on tmdb recommendations based on your existing movies. (#1450)
Keep scroll position on more in search result view. Added TMDB score to search results.
This commit is contained in:
@@ -8,6 +8,7 @@ var ProfileCollection = require('../Profile/ProfileCollection');
|
||||
var AddFromListView = require("./List/AddFromListView");
|
||||
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
||||
var BulkImportView = require("./BulkImport/BulkImportView");
|
||||
var DiscoverMoviesCollection = require("./DiscoverMoviesCollection");
|
||||
require('../Movies/MoviesCollection');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
@@ -22,7 +23,7 @@ module.exports = Marionette.Layout.extend({
|
||||
},
|
||||
|
||||
events : {
|
||||
'click .x-import' : '_importMovies',
|
||||
'click .x-discover' : '_discoverMovies',
|
||||
'click .x-bulk-import' : '_bulkImport',
|
||||
'click .x-add-new' : '_addMovies',
|
||||
"click .x-add-lists" : "_addFromList",
|
||||
@@ -70,10 +71,11 @@ module.exports = Marionette.Layout.extend({
|
||||
this.workspace.show(new BulkImportView({ model : options.model}));
|
||||
},
|
||||
|
||||
_importMovies : function() {
|
||||
this.rootFolderLayout = new RootFolderLayout();
|
||||
this.listenTo(this.rootFolderLayout, 'folderSelected', this._folderSelected);
|
||||
AppLayout.modalRegion.show(this.rootFolderLayout);
|
||||
_discoverMovies : function(options) {
|
||||
options = options || {};
|
||||
options.action = "discover";
|
||||
options.collection = new DiscoverMoviesCollection();
|
||||
this.workspace.show(new AddMoviesView(options));
|
||||
},
|
||||
|
||||
_addMovies : function(options) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="btn-group add-movies-btn-group btn-group-lg btn-block btn-group-collapse">
|
||||
<button class="btn btn-default col-md-3 col-xs-12 x-bulk-import"><i class="icon-sonarr-view-list hidden-xs"></i> Bulk Import Movies</button>
|
||||
<button type="button" class="btn btn-default col-md-4 col-xs-12 add-movies-import-btn x-import"><i class="icon-sonarr-hdd"/>Import existing movies on disk</button>
|
||||
<button type="button" class="btn btn-default col-md-4 col-xs-12 add-movies-import-btn x-discover"><i class="icon-sonarr-star"/> Discover new movies</button>
|
||||
<button class="btn btn-default col-md-2 col-xs-12 x-add-new"><i class="icon-sonarr-active hidden-xs"></i> Add New Movie</button>
|
||||
<button class="btn btn-default col-md-3 col-xs-12 x-add-lists"><i class="icon-sonarr-active hidden-xs"></i> Add Movies from Lists</button>
|
||||
</div>
|
||||
|
@@ -1,4 +1,5 @@
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var vent = require('vent');
|
||||
var Marionette = require('marionette');
|
||||
var AddMoviesCollection = require('./AddMoviesCollection');
|
||||
@@ -7,6 +8,7 @@ var EmptyView = require('./EmptyView');
|
||||
var NotFoundView = require('./NotFoundView');
|
||||
var ErrorView = require('./ErrorView');
|
||||
var LoadingView = require('../Shared/LoadingView');
|
||||
var FullMovieCollection = require("../Movies/FullMovieCollection");
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'AddMovies/AddMoviesViewTemplate',
|
||||
@@ -18,7 +20,8 @@ module.exports = Marionette.Layout.extend({
|
||||
ui : {
|
||||
moviesSearch : '.x-movies-search',
|
||||
searchBar : '.x-search-bar',
|
||||
loadMore : '.x-load-more'
|
||||
loadMore : '.x-load-more',
|
||||
discoverHeader : ".x-discover-header"
|
||||
},
|
||||
|
||||
events : {
|
||||
@@ -27,7 +30,7 @@ module.exports = Marionette.Layout.extend({
|
||||
|
||||
initialize : function(options) {
|
||||
this.isExisting = options.isExisting;
|
||||
this.collection = new AddMoviesCollection();
|
||||
this.collection = options.collection || new AddMoviesCollection();
|
||||
|
||||
if (this.isExisting) {
|
||||
this.collection.unmappedFolderModel = this.model;
|
||||
@@ -51,6 +54,13 @@ module.exports = Marionette.Layout.extend({
|
||||
|
||||
if (options.action === "search") {
|
||||
this.search({term: options.query});
|
||||
} else if (options.action == "discover") {
|
||||
this.isDiscover = true;
|
||||
if (FullMovieCollection.length > 0) {
|
||||
this._discover();
|
||||
} else {
|
||||
this.listenTo(FullMovieCollection, "sync", this._discover);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
@@ -58,6 +68,8 @@ module.exports = Marionette.Layout.extend({
|
||||
onRender : function() {
|
||||
var self = this;
|
||||
|
||||
|
||||
|
||||
this.$el.addClass(this.className);
|
||||
|
||||
this.ui.moviesSearch.keyup(function(e) {
|
||||
@@ -95,10 +107,21 @@ module.exports = Marionette.Layout.extend({
|
||||
if (this.isExisting) {
|
||||
this.ui.searchBar.hide();
|
||||
}
|
||||
|
||||
if (this.isDiscover) {
|
||||
this.ui.searchBar.hide();
|
||||
if (this.collection.length == 0) {
|
||||
this.searchResult.show(new LoadingView());
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onShow : function() {
|
||||
this.ui.discoverHeader.hide();
|
||||
this.ui.moviesSearch.focus();
|
||||
if (this.isDiscover) {
|
||||
this.ui.discoverHeader.show();
|
||||
}
|
||||
},
|
||||
|
||||
search : function(options) {
|
||||
@@ -140,7 +163,10 @@ module.exports = Marionette.Layout.extend({
|
||||
|
||||
_onLoadMore : function() {
|
||||
var showingAll = this.resultCollectionView.showMore();
|
||||
this.ui.searchBar.show();
|
||||
if (!this.isDiscover) {
|
||||
this.ui.searchBar.show();
|
||||
}
|
||||
|
||||
|
||||
if (showingAll) {
|
||||
this.ui.loadMore.hide();
|
||||
@@ -185,5 +211,9 @@ module.exports = Marionette.Layout.extend({
|
||||
this.searchResult.show(new ErrorView({ term : this.collection.term }));
|
||||
this.collection.term = '';
|
||||
}
|
||||
},
|
||||
|
||||
_discover : function() {
|
||||
this.collection.fetch()
|
||||
}
|
||||
});
|
||||
|
@@ -4,6 +4,9 @@
|
||||
{{folder.path}}
|
||||
</div>
|
||||
</div>{{/if}}
|
||||
<h2 class="x-discover-header">
|
||||
Recommendations by The Movie Database based on your library:
|
||||
</h2>
|
||||
<div class="x-search-bar">
|
||||
<div class="input-group input-group-lg add-movies-search">
|
||||
<span class="input-group-addon"><i class="icon-sonarr-search"/></span>
|
||||
|
22
src/UI/AddMovies/DiscoverMoviesCollection.js
Normal file
22
src/UI/AddMovies/DiscoverMoviesCollection.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var Backbone = require('backbone');
|
||||
var MovieModel = require('../Movies/MovieModel');
|
||||
var _ = require('underscore');
|
||||
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + "/movies/discover",
|
||||
model : MovieModel,
|
||||
|
||||
parse : function(response) {
|
||||
var self = this;
|
||||
|
||||
_.each(response, function(model) {
|
||||
model.id = undefined;
|
||||
|
||||
if (self.unmappedFolderModel) {
|
||||
model.path = self.unmappedFolderModel.get('folder').path;
|
||||
}
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
});
|
@@ -2,6 +2,7 @@ var Marionette = require('marionette');
|
||||
var SearchResultView = require('./SearchResultView');
|
||||
var FullMovieCollection = require('../Movies/FullMovieCollection');
|
||||
var vent = require('vent');
|
||||
var $ = require("jquery");
|
||||
|
||||
module.exports = Marionette.CollectionView.extend({
|
||||
itemView : SearchResultView,
|
||||
@@ -28,9 +29,10 @@ module.exports = Marionette.CollectionView.extend({
|
||||
},
|
||||
|
||||
showMore : function() {
|
||||
var pos = $(window).scrollTop();
|
||||
this.showing += 5;
|
||||
this.render();
|
||||
|
||||
$(window).scrollTop(pos);
|
||||
return this.showing >= this.collection.length;
|
||||
},
|
||||
|
||||
|
@@ -26,7 +26,10 @@
|
||||
{{#if_eq status compare="inCinemas"}}
|
||||
<span class="label label-warning">In Cinemas</span>
|
||||
{{/if_eq}}
|
||||
<span class="label label-default" title="{{ratings.votes}} Vote(s)">{{ratings.value}}</span>
|
||||
</span>
|
||||
|
||||
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -307,6 +307,9 @@
|
||||
.icon-sonarr-deleted {
|
||||
.fa-icon-content(@fa-var-trash);
|
||||
}
|
||||
.icon-sonarr-star {
|
||||
.fa-icon-content(@fa-var-star);
|
||||
}
|
||||
|
||||
.icon-sonarr-clear {
|
||||
.fa-icon-content(@fa-var-trash);
|
||||
|
Reference in New Issue
Block a user