diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 187bd42..c841dd2 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -48,6 +48,8 @@ jobs: ClientId: ${{ secrets.MAL_CLIENT_ID }} ClientIdAniList: ${{ secrets.ANILIST_CLIENT_ID }} ClientIdSimkl: ${{ secrets.SIMKL_CLIENT_ID }} + SimklSecret: ${{ secrets.SIMKL_SECRET }} + ClientIdDiscord: ${{ secrets.DISCORD_CLIENT_ID }} - name: 'Build Installer' run: msbuild ${{ env.INSTALLER_PATH }} /property:Configuration=Release /property:BuildVersion=${{ steps.version.outputs.version-without-v }} /property:BasePath=${{ env.PUBLISH_FOLDER }} diff --git a/Totoro.Core/Services/AniList/AniListService.cs b/Totoro.Core/Services/AniList/AniListService.cs index a4c86f1..eb8c27a 100644 --- a/Totoro.Core/Services/AniList/AniListService.cs +++ b/Totoro.Core/Services/AniList/AniListService.cs @@ -115,7 +115,7 @@ public async Task GetBannerImage(long id) { var animeId = await _animeIdService.GetId(_settings.DefaultListService, ListServiceType.AniList, id); - if (animeId is { AniList: null }) + if (animeId is { AniList: null } or null) { return string.Empty; } @@ -133,7 +133,7 @@ public async Task GetBannerImage(long id) { var animeId = await _animeIdService.GetId(_settings.DefaultListService, ListServiceType.AniList, id); - if (animeId is { AniList: null } ) + if (animeId is { AniList: null } or null) { return (null, null); } @@ -141,7 +141,7 @@ public async Task GetBannerImage(long id) var response = await _anilistClient.SendQueryAsync(new GraphQL.GraphQLRequest { Query = new QueryQueryBuilder().WithMedia(new MediaQueryBuilder() - .WithNextAiringEpisode(new AiringScheduleQueryBuilder() + .WithNextAiringEpisode(new AiringScheduleQueryBuilder() .WithEpisode() .WithTimeUntilAiring()), id: (int)animeId.AniList).Build() }); diff --git a/Totoro.Core/Services/DiscordRichPresense.cs b/Totoro.Core/Services/DiscordRichPresense.cs index 215f1b5..eab43fa 100644 --- a/Totoro.Core/Services/DiscordRichPresense.cs +++ b/Totoro.Core/Services/DiscordRichPresense.cs @@ -1,11 +1,12 @@  using DiscordRPC; +using Microsoft.Extensions.Configuration; namespace Totoro.Core.Services; -public class DiscordRichPresense : IDiscordRichPresense +public class DiscordRichPresense(IConfiguration configuration) : IDiscordRichPresense { - private readonly DiscordRpcClient _client = new("997177919052984622"); + private readonly DiscordRpcClient _client = new(configuration["ClientIdDiscord"]); public void Initialize() => _client.Initialize(); public bool IsInitialized => _client.IsInitialized; diff --git a/Totoro.Core/Services/FileService.cs b/Totoro.Core/Services/FileService.cs index 4b05691..3c682c8 100644 --- a/Totoro.Core/Services/FileService.cs +++ b/Totoro.Core/Services/FileService.cs @@ -7,7 +7,8 @@ public class FileService : IFileService { private readonly JsonSerializerSettings _settings = new() { - DefaultValueHandling = DefaultValueHandling.Ignore + DefaultValueHandling = DefaultValueHandling.Ignore, + NullValueHandling = NullValueHandling.Ignore, }; public T Read(string folderPath, string fileName) diff --git a/Totoro.Core/Services/OfflineAnimeIdService.cs b/Totoro.Core/Services/OfflineAnimeIdService.cs index ca4a887..b5d7afc 100644 --- a/Totoro.Core/Services/OfflineAnimeIdService.cs +++ b/Totoro.Core/Services/OfflineAnimeIdService.cs @@ -78,32 +78,34 @@ public async Task UpdateOfflineMappings() var id = new AnimeIdExtended(); var obj = item.AsObject(); - foreach (var key in keys) + foreach (var key in keys.Where(obj.ContainsKey)) { - if (obj.ContainsKey(key)) + var value = obj[key].GetValue(); + switch (key) { - var value = obj[key].GetValue(); - switch (key) - { - case "livechart_id": - id.LiveChart = value; - break; - case "anidb_id": - id.AniDb = value; - break; - case "kitsu_id": - id.Kitsu = value; - break; - case "mal_id": - id.MyAnimeList = value; - break; - case "anilist_id": - id.AniList = value; - break; - } + case "livechart_id": + id.LiveChart = value; + break; + case "anidb_id": + id.AniDb = value; + break; + case "kitsu_id": + id.Kitsu = value; + break; + case "mal_id": + id.MyAnimeList = value; + break; + case "anilist_id": + id.AniList = value; + break; } } + if (id.IsEmpty()) + { + continue; + } + _ids.Add(id); } _idsMap = GetMapping(settings.DefaultListService); diff --git a/Totoro.Core/Services/Simkl/SimklAnimeService.cs b/Totoro.Core/Services/Simkl/SimklAnimeService.cs index 42f52f5..d06ba17 100644 --- a/Totoro.Core/Services/Simkl/SimklAnimeService.cs +++ b/Totoro.Core/Services/Simkl/SimklAnimeService.cs @@ -78,4 +78,6 @@ public bool HasId(ListServiceType type) _ => false }; } + + public bool IsEmpty() => this is { AniDb: null, AniList: null, MyAnimeList: null, Kitsu: null, LiveChart: null, Simkl: null }; } diff --git a/Totoro.WinUI/Views/SettingsSections/AnimePluginsSection.xaml b/Totoro.WinUI/Views/SettingsSections/AnimePluginsSection.xaml index 5c35b28..6314bfd 100644 --- a/Totoro.WinUI/Views/SettingsSections/AnimePluginsSection.xaml +++ b/Totoro.WinUI/Views/SettingsSections/AnimePluginsSection.xaml @@ -75,16 +75,6 @@ OnContent="On" /> - -