mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-22 22:43:31 -07:00
Update import UI & parse titles which contain years
This commit is contained in:
parent
7436997f9b
commit
d9a6c4f211
4 changed files with 37 additions and 6 deletions
|
@ -12,6 +12,7 @@ using NzbDrone.Core.MetadataSource.SkyHook.Resource;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource.SkyHook
|
namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
{
|
{
|
||||||
|
@ -175,9 +176,38 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
return movie;
|
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)
|
public List<Movie> SearchForNewMovie(string title)
|
||||||
{
|
{
|
||||||
var lowerTitle = title.ToLower();
|
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:"))
|
if (lowerTitle.StartsWith("imdb:") || lowerTitle.StartsWith("imdbid:"))
|
||||||
{
|
{
|
||||||
|
@ -209,6 +239,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
.SetSegment("id", "movie")
|
.SetSegment("id", "movie")
|
||||||
.SetSegment("secondaryRoute", "")
|
.SetSegment("secondaryRoute", "")
|
||||||
.AddQueryParam("query", searchTerm)
|
.AddQueryParam("query", searchTerm)
|
||||||
|
.AddQueryParam("year", yearTerm)
|
||||||
.AddQueryParam("include_adult", false)
|
.AddQueryParam("include_adult", false)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ var vent = require('vent');
|
||||||
var AppLayout = require('../AppLayout');
|
var AppLayout = require('../AppLayout');
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var RootFolderLayout = require('./RootFolders/RootFolderLayout');
|
var RootFolderLayout = require('./RootFolders/RootFolderLayout');
|
||||||
//var ExistingMoviesCollectionView = require('./Existing/AddExistingSeriesCollectionView');
|
var ExistingMoviesCollectionView = require('./Existing/AddExistingMovieCollectionView');
|
||||||
var AddMoviesView = require('./AddMoviesView');
|
var AddMoviesView = require('./AddMoviesView');
|
||||||
var ProfileCollection = require('../Profile/ProfileCollection');
|
var ProfileCollection = require('../Profile/ProfileCollection');
|
||||||
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
||||||
|
@ -36,9 +36,9 @@ module.exports = Marionette.Layout.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_folderSelected : function(options) {
|
_folderSelected : function(options) {
|
||||||
//vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
//TODO: Fix this shit.
|
//TODO: Fix this shit.
|
||||||
//this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
|
this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
|
||||||
},
|
},
|
||||||
|
|
||||||
_importMovies : function() {
|
_importMovies : function() {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var AddSeriesView = require('../AddSeriesView');
|
var AddMoviesView = require('../AddMoviesView');
|
||||||
var UnmappedFolderCollection = require('./UnmappedFolderCollection');
|
var UnmappedFolderCollection = require('./UnmappedFolderCollection');
|
||||||
|
|
||||||
module.exports = Marionette.CompositeView.extend({
|
module.exports = Marionette.CompositeView.extend({
|
||||||
itemView : AddSeriesView,
|
itemView : AddMoviesView,
|
||||||
itemViewContainer : '.x-loading-folders',
|
itemViewContainer : '.x-loading-folders',
|
||||||
template : 'AddSeries/Existing/AddExistingSeriesCollectionViewTemplate',
|
template : 'AddMovies/Existing/AddExistingMovieCollectionViewTemplate',
|
||||||
|
|
||||||
ui : {
|
ui : {
|
||||||
loadingFolders : '.x-loading-folders'
|
loadingFolders : '.x-loading-folders'
|
Loading…
Add table
Add a link
Reference in a new issue