2020-05-19 01:14:52 +00:00
|
|
|
using System.Collections.Generic;
|
2019-12-15 07:34:27 +00:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
using NzbDrone.Common.Extensions;
|
2020-09-04 02:50:56 +00:00
|
|
|
using NzbDrone.Core.ImportLists.ImportListMovies;
|
2019-12-15 07:34:27 +00:00
|
|
|
|
2020-09-04 02:50:56 +00:00
|
|
|
namespace NzbDrone.Core.ImportLists.TMDb.List
|
2019-12-15 07:34:27 +00:00
|
|
|
{
|
|
|
|
public class TMDbListParser : TMDbParser
|
|
|
|
{
|
2020-09-04 02:50:56 +00:00
|
|
|
public override IList<ImportListMovie> ParseResponse(ImportListResponse importResponse)
|
2019-12-15 07:34:27 +00:00
|
|
|
{
|
2020-09-04 02:50:56 +00:00
|
|
|
var movies = new List<ImportListMovie>();
|
2019-12-15 07:34:27 +00:00
|
|
|
|
|
|
|
if (!PreProcess(importResponse))
|
|
|
|
{
|
|
|
|
return movies;
|
|
|
|
}
|
|
|
|
|
2020-05-20 01:17:39 +00:00
|
|
|
var jsonResponse = JsonConvert.DeserializeObject<ListResponseResource>(importResponse.Content);
|
2019-12-15 07:34:27 +00:00
|
|
|
|
|
|
|
// no movies were return
|
|
|
|
if (jsonResponse == null)
|
|
|
|
{
|
|
|
|
return movies;
|
|
|
|
}
|
|
|
|
|
2021-03-20 21:08:45 +00:00
|
|
|
foreach (var movie in jsonResponse.Results)
|
2019-12-15 07:34:27 +00:00
|
|
|
{
|
2022-11-20 18:27:45 +00:00
|
|
|
// Media Type is not Movie
|
2021-03-20 21:08:45 +00:00
|
|
|
if (movie.MediaType != "movie")
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-12-15 07:34:27 +00:00
|
|
|
// Movies with no Year Fix
|
2020-05-20 01:17:39 +00:00
|
|
|
if (string.IsNullOrWhiteSpace(movie.ReleaseDate))
|
2019-12-15 07:34:27 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-05-19 02:37:49 +00:00
|
|
|
movies.AddIfNotNull(MapListMovie(movie));
|
2019-12-15 07:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return movies;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|