|
|
|
@ -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 @@ namespace NzbDrone.Core.NetImport.TMDb
|
|
|
|
|
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)
|
|
|
|
|