Radarr/src/NzbDrone.Core/ImportLists/TMDb/List/TMDbListParser.cs

48 lines
1.2 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2019-12-15 07:34:27 +00:00
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.ImportLists.ImportListMovies;
2019-12-15 07:34:27 +00:00
namespace NzbDrone.Core.ImportLists.TMDb.List
2019-12-15 07:34:27 +00:00
{
public class TMDbListParser : TMDbParser
{
public override IList<ImportListMovie> ParseResponse(ImportListResponse importResponse)
2019-12-15 07:34:27 +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;
}
movies.AddIfNotNull(MapListMovie(movie));
2019-12-15 07:34:27 +00:00
}
return movies;
}
}
}