mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-17 21:26:13 -04:00
New: Minimum Score for MAL Import List
This commit is contained in:
@@ -74,7 +74,7 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
|
||||
public override IParseImportListResponse GetParser()
|
||||
{
|
||||
return new MyAnimeListParser();
|
||||
return new MyAnimeListParser(Settings);
|
||||
}
|
||||
|
||||
public override IImportListRequestGenerator GetRequestGenerator()
|
||||
|
||||
@@ -7,9 +7,10 @@ using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
{
|
||||
public class MyAnimeListParser : IParseImportListResponse
|
||||
public class MyAnimeListParser(MyAnimeListSettings settings) : IParseImportListResponse
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(MyAnimeListParser));
|
||||
private readonly MyAnimeListSettings _settings = settings;
|
||||
|
||||
public IList<ImportListItemInfo> ParseResponse(ImportListResponse importListResponse)
|
||||
{
|
||||
@@ -18,6 +19,12 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
|
||||
foreach (var show in jsonResponse.Animes)
|
||||
{
|
||||
if (show.ListStatus.Score < _settings.MinimumScore)
|
||||
{
|
||||
Logger.Debug("Skipping {0} because score is below threshold", show.AnimeListInfo.Title);
|
||||
continue;
|
||||
}
|
||||
|
||||
series.AddIfNotNull(new ImportListItemInfo
|
||||
{
|
||||
Title = show.AnimeListInfo.Title,
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
public class MyAnimeListStatusResult
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public int Score { get; set; }
|
||||
}
|
||||
|
||||
public class MyAnimeListItemInfo
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
.OverridePropertyName("SignIn")
|
||||
.WithMessage("Must authenticate with MyAnimeList");
|
||||
|
||||
RuleFor(c => c.MinimumScore)
|
||||
.InclusiveBetween(0, 10)
|
||||
.WithMessage("Must be between 0 and 10");
|
||||
|
||||
RuleFor(c => c.ListStatus).Custom((status, context) =>
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(MyAnimeListStatus), status))
|
||||
@@ -33,6 +37,9 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||
[FieldDefinition(0, Label = "ImportListsMyAnimeListSettingsListStatus", Type = FieldType.Select, SelectOptions = typeof(MyAnimeListStatus), HelpText = "ImportListsMyAnimeListSettingsListStatusHelpText")]
|
||||
public int ListStatus { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "ImportListsMyAnimeListSettingsScore", HelpText = "ImportListsMyAnimeListSettingsScoreHelpText")]
|
||||
public int MinimumScore { get; set; } = 0;
|
||||
|
||||
[FieldDefinition(0, Label = "ImportListsSettingsAccessToken", Type = FieldType.Textbox, Hidden = HiddenType.Hidden)]
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
|
||||
@@ -881,6 +881,8 @@
|
||||
"ImportListsAniListSettingsImportWatching": "Import Watching",
|
||||
"ImportListsAniListSettingsImportWatchingHelpText": "List: Currently Watching",
|
||||
"ImportListsAniListSettingsUsernameHelpText": "Username for the List to import from",
|
||||
"ImportListsMyAnimeListSettingsScore": "Minimum Score",
|
||||
"ImportListsMyAnimeListSettingsScoreHelpText": "Minimum score for shows to be imported",
|
||||
"ImportListsCustomListSettingsName": "Custom List",
|
||||
"ImportListsCustomListSettingsUrl": "List URL",
|
||||
"ImportListsCustomListSettingsUrlHelpText": "The URL for the series list",
|
||||
|
||||
Reference in New Issue
Block a user