From 7fd74f59ad553d8555ecccd09e23e950aac5bf05 Mon Sep 17 00:00:00 2001 From: iceypotato Date: Mon, 17 Jul 2023 10:54:09 -0700 Subject: [PATCH] Added files for anime importing --- .../ImportLists/MyAnimeList/MalImport.cs | 38 +++++++++++++++++++ .../MyAnimeList/MalListSettings.cs | 30 +++++++++++++++ .../ImportLists/MyAnimeList/MalParser.cs | 14 +++++++ .../MyAnimeList/MalRequestGenerator.cs | 14 +++++++ 4 files changed, 96 insertions(+) create mode 100644 src/NzbDrone.Core/ImportLists/MyAnimeList/MalImport.cs create mode 100644 src/NzbDrone.Core/ImportLists/MyAnimeList/MalListSettings.cs create mode 100644 src/NzbDrone.Core/ImportLists/MyAnimeList/MalParser.cs create mode 100644 src/NzbDrone.Core/ImportLists/MyAnimeList/MalRequestGenerator.cs diff --git a/src/NzbDrone.Core/ImportLists/MyAnimeList/MalImport.cs b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalImport.cs new file mode 100644 index 000000000..1b0b1353f --- /dev/null +++ b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalImport.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using NLog; +using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Parser; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.ImportLists.MyAnimeList +{ + internal class MalImport : HttpImportListBase + { + public override string Name => "MyAnimeList"; + public override ImportListType ListType => ImportListType.Other; + public override TimeSpan MinRefreshInterval => throw new NotImplementedException(); + + // This constructor the first thing that is called when sonarr creates a button + public MalImport(IHttpClient httpClient, IImportListStatusService importListStatusService, IConfigService configService, IParsingService parsingService, Logger logger) + : base(httpClient, importListStatusService, configService, parsingService, logger) + { + } + + public override IList Fetch() + { + return FetchItems(g => g.GetListItems()); + } + + public override IParseImportListResponse GetParser() + { + return new MalParser(); + } + + public override IImportListRequestGenerator GetRequestGenerator() + { + return new MalRequestGenerator(); + } + } +} diff --git a/src/NzbDrone.Core/ImportLists/MyAnimeList/MalListSettings.cs b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalListSettings.cs new file mode 100644 index 000000000..bef813539 --- /dev/null +++ b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalListSettings.cs @@ -0,0 +1,30 @@ +using FluentValidation; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.ImportLists.MyAnimeList +{ + internal class MalSettingsValidator : AbstractValidator + { + public MalSettingsValidator() + { + } + } + + internal class MalListSettings : IImportListSettings + { + public string BaseUrl { get; set; } + + protected AbstractValidator Validator => new MalSettingsValidator(); + + // This constructor is called when we try to add a new list + public MalListSettings() + { + BaseUrl = ""; + } + + public NzbDroneValidationResult Validate() + { + return new NzbDroneValidationResult(Validator.Validate(this)); + } + } +} diff --git a/src/NzbDrone.Core/ImportLists/MyAnimeList/MalParser.cs b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalParser.cs new file mode 100644 index 000000000..70db23b97 --- /dev/null +++ b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalParser.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.ImportLists.MyAnimeList +{ + internal class MalParser : IParseImportListResponse + { + public IList ParseResponse(ImportListResponse importListResponse) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/NzbDrone.Core/ImportLists/MyAnimeList/MalRequestGenerator.cs b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalRequestGenerator.cs new file mode 100644 index 000000000..dc2ad29c9 --- /dev/null +++ b/src/NzbDrone.Core/ImportLists/MyAnimeList/MalRequestGenerator.cs @@ -0,0 +1,14 @@ +namespace NzbDrone.Core.ImportLists.MyAnimeList +{ + internal class MalRequestGenerator : IImportListRequestGenerator + { + public ImportListPageableRequestChain GetListItems() + { + var pageableReq = new ImportListPageableRequestChain(); + /* + * create + */ + return pageableReq; + } + } +}