|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
|
|
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
|
using NzbDrone.Core.ImportLists.Exceptions;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
@ -10,6 +12,11 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|
|
|
|
public class SimklParser : IParseImportListResponse
|
|
|
|
|
{
|
|
|
|
|
private ImportListResponse _importResponse;
|
|
|
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(SimklParser));
|
|
|
|
|
|
|
|
|
|
public SimklParser()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IList<ImportListItemInfo> ParseResponse(ImportListResponse importResponse)
|
|
|
|
|
{
|
|
|
|
@ -22,7 +29,7 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|
|
|
|
return series;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jsonResponse = STJson.Deserialize<SimklResponse>(_importResponse.Content);
|
|
|
|
|
var jsonResponse = Json.Deserialize<SimklResponse>(_importResponse.Content);
|
|
|
|
|
|
|
|
|
|
// no shows were return
|
|
|
|
|
if (jsonResponse == null)
|
|
|
|
@ -30,14 +37,40 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|
|
|
|
return series;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var show in jsonResponse.Shows)
|
|
|
|
|
if (jsonResponse.Anime != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var show in jsonResponse.Anime)
|
|
|
|
|
{
|
|
|
|
|
var tentativeTvdbId = int.TryParse(show.Show.Ids.Tvdb, out var tvdbId) ? tvdbId : 0;
|
|
|
|
|
|
|
|
|
|
if (tentativeTvdbId > 0 && show.AnimeType == SimklAnimeType.Tv)
|
|
|
|
|
{
|
|
|
|
|
series.AddIfNotNull(new ImportListItemInfo()
|
|
|
|
|
{
|
|
|
|
|
Title = show.Show.Title,
|
|
|
|
|
ImdbId = show.Show.Ids.Imdb,
|
|
|
|
|
TvdbId = tvdbId,
|
|
|
|
|
MalId = int.TryParse(show.Show.Ids.Mal, out var malId) ? malId : 0
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Logger.Warn("Skipping info grabbing for '{0}' because it is a movie or it is not the first season of the show", show.Show.Title);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (jsonResponse.Shows != null)
|
|
|
|
|
{
|
|
|
|
|
series.AddIfNotNull(new ImportListItemInfo()
|
|
|
|
|
foreach (var show in jsonResponse.Shows)
|
|
|
|
|
{
|
|
|
|
|
Title = show.Show.Title,
|
|
|
|
|
TvdbId = int.TryParse(show.Show.Ids.Tvdb, out var tvdbId) ? tvdbId : 0,
|
|
|
|
|
ImdbId = show.Show.Ids.Imdb
|
|
|
|
|
});
|
|
|
|
|
series.AddIfNotNull(new ImportListItemInfo()
|
|
|
|
|
{
|
|
|
|
|
Title = show.Show.Title,
|
|
|
|
|
TvdbId = int.TryParse(show.Show.Ids.Tvdb, out var tvdbId) ? tvdbId : 0,
|
|
|
|
|
ImdbId = show.Show.Ids.Imdb
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return series;
|
|
|
|
|