New: Simkl Anime List integration
Co-authored-by: iceypotato <nickyjedi@gmail.com> Closes #5635
This commit is contained in:
parent
180153cd84
commit
b779c92200
|
@ -11,6 +11,7 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|||
public string Imdb { get; set; }
|
||||
public string Tmdb { get; set; }
|
||||
public string Tvdb { get; set; }
|
||||
public string Mal { get; set; }
|
||||
}
|
||||
|
||||
public class SimklSeriesPropsResource
|
||||
|
@ -23,11 +24,15 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|||
public class SimklSeriesResource
|
||||
{
|
||||
public SimklSeriesPropsResource Show { get; set; }
|
||||
|
||||
[JsonProperty("anime_type")]
|
||||
public SimklAnimeType AnimeType { get; set; }
|
||||
}
|
||||
|
||||
public class SimklResponse
|
||||
{
|
||||
public List<SimklSeriesResource> Shows { get; set; }
|
||||
public List<SimklSeriesResource> Anime { get; set; }
|
||||
}
|
||||
|
||||
public class RefreshRequestResponse
|
||||
|
@ -66,4 +71,10 @@ namespace NzbDrone.Core.ImportLists.Simkl
|
|||
{
|
||||
public DateTime All { get; set; }
|
||||
}
|
||||
|
||||
public enum SimklAnimeType
|
||||
{
|
||||
Tv,
|
||||
Movie
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
series.AddIfNotNull(new ImportListItemInfo()
|
||||
foreach (var show in jsonResponse.Anime)
|
||||
{
|
||||
Title = show.Show.Title,
|
||||
TvdbId = int.TryParse(show.Show.Ids.Tvdb, out var tvdbId) ? tvdbId : 0,
|
||||
ImdbId = show.Show.Ids.Imdb
|
||||
});
|
||||
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)
|
||||
{
|
||||
foreach (var show in jsonResponse.Shows)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.ImportLists.Simkl.User
|
|||
|
||||
private IEnumerable<ImportListRequest> GetSeriesRequest()
|
||||
{
|
||||
var link = $"{Settings.BaseUrl.Trim()}/sync/all-items/shows/{((SimklUserListType)Settings.ListType).ToString().ToLowerInvariant()}";
|
||||
var link = $"{Settings.BaseUrl.Trim()}/sync/all-items/{((SimklUserShowType)Settings.ShowType).ToString().ToLowerInvariant()}/{((SimklUserListType)Settings.ListType).ToString().ToLowerInvariant()}";
|
||||
|
||||
var request = new ImportListRequest(link, HttpAccept.Json);
|
||||
|
||||
|
|
|
@ -19,9 +19,13 @@ namespace NzbDrone.Core.ImportLists.Simkl.User
|
|||
public SimklUserSettings()
|
||||
{
|
||||
ListType = (int)SimklUserListType.Watching;
|
||||
ShowType = (int)SimklUserShowType.Shows;
|
||||
}
|
||||
|
||||
[FieldDefinition(1, Label = "List Type", Type = FieldType.Select, SelectOptions = typeof(SimklUserListType), HelpText = "Type of list you're seeking to import from")]
|
||||
public int ListType { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Show Type", Type = FieldType.Select, SelectOptions = typeof(SimklUserShowType), HelpText = "Type of show you're seeking to import from")]
|
||||
public int ShowType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
namespace NzbDrone.Core.ImportLists.Simkl.User
|
||||
{
|
||||
public enum SimklUserShowType
|
||||
{
|
||||
Shows = 0,
|
||||
Anime = 1
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ namespace NzbDrone.Core.Parser.Model
|
|||
public int TvdbId { get; set; }
|
||||
public int TmdbId { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public int MalId { get; set; }
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
|
|
Loading…
Reference in New Issue