mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Map properties returned from TMDB lists to avoid needing server re-mapping
This commit is contained in:
parent
2bdd806565
commit
50f84101e0
@ -456,18 +456,6 @@ private static AlternativeTitle MapAlternativeTitle(AlternativeTitleResource arg
|
||||
return newAlternativeTitle;
|
||||
}
|
||||
|
||||
private static MovieCollection MapCollection(CollectionResource arg)
|
||||
{
|
||||
var newCollection = new MovieCollection
|
||||
{
|
||||
Name = arg.Name,
|
||||
TmdbId = arg.TmdbId,
|
||||
Images = arg.Images.Select(MapImage).ToList()
|
||||
};
|
||||
|
||||
return newCollection;
|
||||
}
|
||||
|
||||
private static Ratings MapRatings(RatingResource rating)
|
||||
{
|
||||
if (rating == null)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
@ -25,7 +25,7 @@ public TMDbCollectionImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
|
||||
public override IParseNetImportResponse GetParser()
|
||||
{
|
||||
return new TMDbCollectionParser(_skyhookProxy);
|
||||
return new TMDbCollectionParser();
|
||||
}
|
||||
|
||||
public override INetImportRequestGenerator GetRequestGenerator()
|
||||
|
@ -8,14 +8,6 @@ namespace NzbDrone.Core.NetImport.TMDb.Collection
|
||||
{
|
||||
public class TMDbCollectionParser : TMDbParser
|
||||
{
|
||||
private readonly ISearchForNewMovie _skyhookProxy;
|
||||
|
||||
public TMDbCollectionParser(ISearchForNewMovie skyhookProxy)
|
||||
: base(skyhookProxy)
|
||||
{
|
||||
_skyhookProxy = skyhookProxy;
|
||||
}
|
||||
|
||||
public override IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
@ -41,7 +33,7 @@ public override IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
continue;
|
||||
}
|
||||
|
||||
movies.AddIfNotNull(new Movie { TmdbId = movie.id });
|
||||
movies.AddIfNotNull(MapListMovie(movie));
|
||||
}
|
||||
|
||||
return movies;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
@ -25,7 +25,7 @@ public TMDbListImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
|
||||
public override IParseNetImportResponse GetParser()
|
||||
{
|
||||
return new TMDbListParser(_skyhookProxy);
|
||||
return new TMDbListParser();
|
||||
}
|
||||
|
||||
public override INetImportRequestGenerator GetRequestGenerator()
|
||||
|
@ -8,14 +8,6 @@ namespace NzbDrone.Core.NetImport.TMDb.List
|
||||
{
|
||||
public class TMDbListParser : TMDbParser
|
||||
{
|
||||
private readonly ISearchForNewMovie _skyhookProxy;
|
||||
|
||||
public TMDbListParser(ISearchForNewMovie skyhookProxy)
|
||||
: base(skyhookProxy)
|
||||
{
|
||||
_skyhookProxy = skyhookProxy;
|
||||
}
|
||||
|
||||
public override IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
@ -41,7 +33,7 @@ public override IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
continue;
|
||||
}
|
||||
|
||||
movies.AddIfNotNull(new Movie { TmdbId = movie.id });
|
||||
movies.AddIfNotNull(MapListMovie(movie));
|
||||
}
|
||||
|
||||
return movies;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
@ -25,7 +25,7 @@ public TMDbPersonImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
|
||||
public override IParseNetImportResponse GetParser()
|
||||
{
|
||||
return new TMDbPersonParser(Settings, _skyhookProxy);
|
||||
return new TMDbPersonParser(Settings);
|
||||
}
|
||||
|
||||
public override INetImportRequestGenerator GetRequestGenerator()
|
||||
|
@ -9,13 +9,10 @@ namespace NzbDrone.Core.NetImport.TMDb.Person
|
||||
public class TMDbPersonParser : TMDbParser
|
||||
{
|
||||
private readonly TMDbPersonSettings _settings;
|
||||
private readonly ISearchForNewMovie _skyhookProxy;
|
||||
|
||||
public TMDbPersonParser(TMDbPersonSettings settings, ISearchForNewMovie skyhookProxy)
|
||||
: base(skyhookProxy)
|
||||
public TMDbPersonParser(TMDbPersonSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
_skyhookProxy = skyhookProxy;
|
||||
}
|
||||
|
||||
public override IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
@ -25,7 +25,7 @@ public TMDbPopularImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
|
||||
public override IParseNetImportResponse GetParser()
|
||||
{
|
||||
return new TMDbParser(_skyhookProxy);
|
||||
return new TMDbParser();
|
||||
}
|
||||
|
||||
public override INetImportRequestGenerator GetRequestGenerator()
|
||||
|
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.NetImport.Exceptions;
|
||||
@ -10,13 +13,6 @@ namespace NzbDrone.Core.NetImport.TMDb
|
||||
{
|
||||
public class TMDbParser : IParseNetImportResponse
|
||||
{
|
||||
private readonly ISearchForNewMovie _skyhookProxy;
|
||||
|
||||
public TMDbParser(ISearchForNewMovie skyhookProxy)
|
||||
{
|
||||
_skyhookProxy = skyhookProxy;
|
||||
}
|
||||
|
||||
public virtual IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
@ -34,7 +30,39 @@ public virtual IList<Movie> ParseResponse(NetImportResponse importResponse)
|
||||
return movies;
|
||||
}
|
||||
|
||||
return jsonResponse.Results.SelectList(m => new Movie { TmdbId = m.id });
|
||||
return jsonResponse.Results.SelectList(MapListMovie);
|
||||
}
|
||||
|
||||
protected Movie MapListMovie(MovieResult movieResult)
|
||||
{
|
||||
var movie = new Movie
|
||||
{
|
||||
TmdbId = movieResult.id,
|
||||
Overview = movieResult.overview,
|
||||
Title = movieResult.original_title,
|
||||
SortTitle = Parser.Parser.NormalizeTitle(movieResult.original_title),
|
||||
Images = new List<MediaCover.MediaCover>()
|
||||
};
|
||||
|
||||
if (movieResult.release_date.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
DateTime.TryParse(movieResult.release_date, out var releaseDate);
|
||||
movie.Year = releaseDate.Year;
|
||||
}
|
||||
|
||||
movie.Images.AddIfNotNull(MapPosterImage(movieResult.poster_path));
|
||||
|
||||
return movie;
|
||||
}
|
||||
|
||||
private MediaCover.MediaCover MapPosterImage(string path)
|
||||
{
|
||||
if (path.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return new MediaCover.MediaCover(MediaCoverTypes.Poster, $"https://image.tmdb.org/t/p/original{path}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual bool PreProcess(NetImportResponse listResponse)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
@ -27,7 +27,7 @@ public TMDbUserImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
|
||||
public override IParseNetImportResponse GetParser()
|
||||
{
|
||||
return new TMDbParser(_skyhookProxy);
|
||||
return new TMDbParser();
|
||||
}
|
||||
|
||||
public override INetImportRequestGenerator GetRequestGenerator()
|
||||
|
Loading…
Reference in New Issue
Block a user