mirror of https://github.com/Radarr/Radarr
Merge pull request #45 from fedoranimus/develop
Enables the Import UI & parses movie titles which contain year
This commit is contained in:
commit
da404d6435
|
@ -12,6 +12,7 @@ using NzbDrone.Core.MetadataSource.SkyHook.Resource;
|
|||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Tv;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
{
|
||||
|
@ -175,9 +176,38 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
return movie;
|
||||
}
|
||||
|
||||
private string[] SeparateYearFromTitle(string title)
|
||||
{
|
||||
var yearPattern = @"((?:19|20)\d{2})";
|
||||
var newTitle = title;
|
||||
var substrings = Regex.Split(title, yearPattern);
|
||||
var year = "";
|
||||
if (substrings.Length > 1) {
|
||||
newTitle = substrings[0].TrimEnd("(");
|
||||
year = substrings[1];
|
||||
}
|
||||
|
||||
return new[] { newTitle.Trim(), year.Trim() };
|
||||
}
|
||||
|
||||
private string StripTrailingTheFromTitle(string title)
|
||||
{
|
||||
if(title.EndsWith(", the") || title.EndsWith(",the"))
|
||||
{
|
||||
title = title.Substring(title.Length - 4);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
public List<Movie> SearchForNewMovie(string title)
|
||||
{
|
||||
var lowerTitle = title.ToLower();
|
||||
var yearCheck = SeparateYearFromTitle(lowerTitle); // TODO: Make this much less hacky!
|
||||
|
||||
lowerTitle = yearCheck[0];
|
||||
var yearTerm = yearCheck[1];
|
||||
|
||||
lowerTitle = StripTrailingTheFromTitle(lowerTitle);
|
||||
|
||||
if (lowerTitle.StartsWith("imdb:") || lowerTitle.StartsWith("imdbid:"))
|
||||
{
|
||||
|
@ -209,6 +239,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
.SetSegment("id", "movie")
|
||||
.SetSegment("secondaryRoute", "")
|
||||
.AddQueryParam("query", searchTerm)
|
||||
.AddQueryParam("year", yearTerm)
|
||||
.AddQueryParam("include_adult", false)
|
||||
.Build();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ var vent = require('vent');
|
|||
var AppLayout = require('../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var RootFolderLayout = require('./RootFolders/RootFolderLayout');
|
||||
//var ExistingMoviesCollectionView = require('./Existing/AddExistingSeriesCollectionView');
|
||||
var ExistingMoviesCollectionView = require('./Existing/AddExistingMovieCollectionView');
|
||||
var AddMoviesView = require('./AddMoviesView');
|
||||
var ProfileCollection = require('../Profile/ProfileCollection');
|
||||
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
||||
|
@ -36,9 +36,9 @@ module.exports = Marionette.Layout.extend({
|
|||
},
|
||||
|
||||
_folderSelected : function(options) {
|
||||
//vent.trigger(vent.Commands.CloseModalCommand);
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
//TODO: Fix this shit.
|
||||
//this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
|
||||
this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
|
||||
},
|
||||
|
||||
_importMovies : function() {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
var Marionette = require('marionette');
|
||||
var AddSeriesView = require('../AddSeriesView');
|
||||
var AddMoviesView = require('../AddMoviesView');
|
||||
var UnmappedFolderCollection = require('./UnmappedFolderCollection');
|
||||
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
itemView : AddSeriesView,
|
||||
itemView : AddMoviesView,
|
||||
itemViewContainer : '.x-loading-folders',
|
||||
template : 'AddSeries/Existing/AddExistingSeriesCollectionViewTemplate',
|
||||
template : 'AddMovies/Existing/AddExistingMovieCollectionViewTemplate',
|
||||
|
||||
ui : {
|
||||
loadingFolders : '.x-loading-folders'
|
Loading…
Reference in New Issue