mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-08 04:50:56 +02:00
Refactor show type handling in Simkl import logic and settings
This commit is contained in:
parent
5282d17911
commit
3aa68122d2
3 changed files with 14 additions and 6 deletions
|
|
@ -111,7 +111,16 @@ private DateTime GetLastActivity()
|
|||
|
||||
if (response?.Resource != null)
|
||||
{
|
||||
return (SimklUserShowType)Settings.ShowType == SimklUserShowType.Shows ? response.Resource.TvShows.All : response.Resource.Anime.All;
|
||||
var showType = SimklUserShowType.Shows;
|
||||
|
||||
if (Settings is SimklUserSettings userSettings)
|
||||
{
|
||||
showType = (SimklUserShowType)userSettings.ShowType;
|
||||
}
|
||||
|
||||
return showType == SimklUserShowType.Shows
|
||||
? response.Resource.TvShows.All
|
||||
: response.Resource.Anime.All;
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using FluentValidation;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ImportLists.Simkl.User;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.Simkl
|
||||
|
|
@ -33,7 +32,6 @@ public class SimklSettingsBase<TSettings> : ImportListSettingsBase<TSettings>
|
|||
public SimklSettingsBase()
|
||||
{
|
||||
SignIn = "startOAuth";
|
||||
ShowType = (int)SimklUserShowType.Shows;
|
||||
}
|
||||
|
||||
public override string BaseUrl { get; set; } = "https://api.simkl.com";
|
||||
|
|
@ -53,9 +51,6 @@ public SimklSettingsBase()
|
|||
[FieldDefinition(99, Label = "ImportListsSimklSettingsAuthenticatewithSimkl", Type = FieldType.OAuth)]
|
||||
public string SignIn { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "ImportListsSimklSettingsShowType", Type = FieldType.Select, SelectOptions = typeof(SimklUserShowType), HelpText = "ImportListsSimklSettingsShowTypeHelpText")]
|
||||
public int ShowType { get; set; }
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate((TSettings)this));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,15 @@ public class SimklUserSettings : SimklSettingsBase<SimklUserSettings>
|
|||
public SimklUserSettings()
|
||||
{
|
||||
ListType = (int)SimklUserListType.Watching;
|
||||
ShowType = (int)SimklUserShowType.Shows;
|
||||
}
|
||||
|
||||
[FieldDefinition(1, Label = "ImportListsSimklSettingsListType", Type = FieldType.Select, SelectOptions = typeof(SimklUserListType), HelpText = "ImportListsSimklSettingsListTypeHelpText")]
|
||||
public int ListType { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "ImportListsSimklSettingsShowType", Type = FieldType.Select, SelectOptions = typeof(SimklUserShowType), HelpText = "ImportListsSimklSettingsShowTypeHelpText")]
|
||||
public int ShowType { get; set; }
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
|
|
|
|||
Loading…
Reference in a new issue