From 307c5f650fd8d90f0851efc898ac6b3866c49674 Mon Sep 17 00:00:00 2001 From: Harshith Mohan <26010946+harshithmohan@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:52:01 +0530 Subject: [PATCH] Update `Shoko.Plugin.Abstractions` to `3.0.0-alpha11` --- Helpers/DiscordHelper.cs | 9 +++++---- Helpers/Interfaces/IDiscordHelper.cs | 3 ++- Helpers/Interfaces/IShokoHelper.cs | 3 ++- Helpers/ShokoHelper.cs | 3 ++- WebhookDump.cs | 16 ++++++++-------- WebhookDump.csproj | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Helpers/DiscordHelper.cs b/Helpers/DiscordHelper.cs index b73dd3c..ddc17e6 100644 --- a/Helpers/DiscordHelper.cs +++ b/Helpers/DiscordHelper.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using NLog; using Shoko.Plugin.Abstractions.DataModels; +using Shoko.Plugin.Abstractions.DataModels.Shoko; using Shoko.Plugin.WebhookDump.Models.AniDB; using Shoko.Plugin.WebhookDump.Models.Discord; using Shoko.Plugin.WebhookDump.Settings; @@ -64,7 +65,7 @@ public async Task SendWebhook(IVideoFile file, string dumpResult, AniDBS } } - public async Task PatchWebhook(IVideoFile file, IAnime anime, IEpisode episode, MemoryStream imageStream, string messageId) + public async Task PatchWebhook(IVideoFile file, IShokoSeries anime, IEpisode episode, MemoryStream imageStream, string messageId) { _logger.Info(CultureInfo.InvariantCulture, "Attempting to update Discord message (fileId={fileId}, messageId={messageId})", file.VideoID, messageId); @@ -124,7 +125,7 @@ private Webhook GetUnmatchedWebhook(IVideoFile file, string dumpResult, AniDBSea }; } - private Webhook GetMatchedWebhook(IVideoFile file, IAnime anime, IEpisode episode) + private Webhook GetMatchedWebhook(IVideoFile file, IShokoSeries anime, IEpisode episode) { UriBuilder publicUrl = new(_settings.Shoko.PublicUrl) { @@ -186,7 +187,7 @@ private static List GetUnmatchedFields(string dumpResult, AniDBSea return output; } - private static List GetMatchedFields(IAnime series, IEpisode episode) + private static List GetMatchedFields(IShokoSeries series, IEpisode episode) { AnimeTitle episodeTitle = episode.Titles.FirstOrDefault(t => t.Language == TitleLanguage.English); string episodeNumber = episode.EpisodeNumber.ToString("00", CultureInfo.InvariantCulture); @@ -211,7 +212,7 @@ private static WebhookFooter GetFooter(IVideoFile file) { return new WebhookFooter() { - Text = $"File ID: {file.VideoID} | CRC: {file.VideoInfo.Hashes.CRC}{(file.FileName.Contains($"[{file.VideoInfo.Hashes.CRC}]") ? " | CRC in filename" : string.Empty)}" + Text = $"File ID: {file.VideoID} | CRC: {file.Video?.Hashes.CRC}{(file.FileName.Contains($"[{file.Video?.Hashes.CRC}]") ? " | CRC in filename" : string.Empty)}" }; } diff --git a/Helpers/Interfaces/IDiscordHelper.cs b/Helpers/Interfaces/IDiscordHelper.cs index 120e295..3afc724 100644 --- a/Helpers/Interfaces/IDiscordHelper.cs +++ b/Helpers/Interfaces/IDiscordHelper.cs @@ -1,6 +1,7 @@ using System.IO; using System.Threading.Tasks; using Shoko.Plugin.Abstractions.DataModels; +using Shoko.Plugin.Abstractions.DataModels.Shoko; using Shoko.Plugin.WebhookDump.Models.AniDB; namespace Shoko.Plugin.WebhookDump.Apis; @@ -8,7 +9,7 @@ namespace Shoko.Plugin.WebhookDump.Apis; public interface IDiscordHelper { void Dispose(); - Task PatchWebhook(IVideoFile file, IAnime anime, IEpisode episode, MemoryStream imageStream, string messageId); + Task PatchWebhook(IVideoFile file, IShokoSeries anime, IEpisode episode, MemoryStream imageStream, string messageId); Task SendWebhook(IVideoFile file, string dumpResult, AniDBSearchResult searchResult); Task GetMessageReactionState(string messageId); } diff --git a/Helpers/Interfaces/IShokoHelper.cs b/Helpers/Interfaces/IShokoHelper.cs index 7b4c47a..c096eb0 100644 --- a/Helpers/Interfaces/IShokoHelper.cs +++ b/Helpers/Interfaces/IShokoHelper.cs @@ -1,6 +1,7 @@ using System.IO; using System.Threading.Tasks; using Shoko.Plugin.Abstractions.DataModels; +using Shoko.Plugin.Abstractions.DataModels.Shoko; using Shoko.Plugin.WebhookDump.Models.AniDB; namespace Shoko.Plugin.WebhookDump.Apis; @@ -10,7 +11,7 @@ public interface IShokoHelper void Dispose(); Task DumpFile(int fileId); Task GetImageStream(AniDBPoster poster); - Task GetSeriesPoster(IAnime anime); + Task GetSeriesPoster(IShokoSeries anime); Task MatchTitle(string filename); Task ScanFile(IVideoFile file, int autoMatchAttempts = 1); Task ScanFileById(int fileId); diff --git a/Helpers/ShokoHelper.cs b/Helpers/ShokoHelper.cs index 1eebc99..f330acc 100644 --- a/Helpers/ShokoHelper.cs +++ b/Helpers/ShokoHelper.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using NLog; using Shoko.Plugin.Abstractions.DataModels; +using Shoko.Plugin.Abstractions.DataModels.Shoko; using Shoko.Plugin.WebhookDump.Models.AniDB; using Shoko.Plugin.WebhookDump.Settings; @@ -113,7 +114,7 @@ public async Task ScanFileById(int fileId) } } - public async Task GetSeriesPoster(IAnime anime) + public async Task GetSeriesPoster(IShokoSeries anime) { try { diff --git a/WebhookDump.cs b/WebhookDump.cs index 740cb4f..4b6f1ef 100644 --- a/WebhookDump.cs +++ b/WebhookDump.cs @@ -1,12 +1,12 @@ using System; using System.IO; -using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NLog; using Shoko.Plugin.Abstractions; using Shoko.Plugin.Abstractions.DataModels; +using Shoko.Plugin.Abstractions.DataModels.Shoko; using Shoko.Plugin.WebhookDump.Apis; using Shoko.Plugin.WebhookDump.Models.AniDB; using Shoko.Plugin.WebhookDump.Settings; @@ -68,7 +68,7 @@ public void Load() private void OnFileNotMatched(object sender, FileNotMatchedEventArgs fileNotMatchedEvent) { - IVideoFile fileInfo = fileNotMatchedEvent.FileInfo; + IVideoFile fileInfo = fileNotMatchedEvent.File; int matchAttempts = fileNotMatchedEvent.AutoMatchAttempts; if (!IsProbablyAnime(fileInfo) || fileNotMatchedEvent.HasCrossReferences) @@ -79,7 +79,7 @@ private void OnFileNotMatched(object sender, FileNotMatchedEventArgs fileNotMatc if (matchAttempts == 1) { _fileTracker.TryAddFile(fileInfo); - _ = Task.Run(() => _shokoHelper.DumpFile(fileInfo.VideoID)).ConfigureAwait(false); ; + _ = Task.Run(() => _shokoHelper.DumpFile(fileInfo.VideoID)).ConfigureAwait(false); } if ( @@ -99,19 +99,19 @@ private void OnFileNotMatched(object sender, FileNotMatchedEventArgs fileNotMatc } } - private async void OnFileMatched(object sender, FileMatchedEventArgs fileMatchedEvent) + private async void OnFileMatched(object sender, FileEventArgs fileMatchedEvent) { - IVideoFile fileInfo = fileMatchedEvent.FileInfo; + IVideoFile fileInfo = fileMatchedEvent.File; - if (fileMatchedEvent.AnimeInfo.Count == 0 || fileMatchedEvent.EpisodeInfo.Count == 0) + if (fileMatchedEvent.Series.Count == 0 || fileMatchedEvent.Episodes.Count == 0) { // we don't want the plugin to panic here... so we'll just ignore that this ever happened. // This appears to happen for when a series is new to Shoko, the episode info is pulled after the XRefs are created and matched. return; } - IAnime animeInfo = fileMatchedEvent.AnimeInfo[0]; - IEpisode episodeInfo = fileMatchedEvent.EpisodeInfo[0]; + IShokoSeries animeInfo = fileMatchedEvent.Series[0]; + IShokoEpisode episodeInfo = fileMatchedEvent.Episodes[0]; if (!_fileTracker.TryRemoveFile(fileInfo.VideoID)) { diff --git a/WebhookDump.csproj b/WebhookDump.csproj index a31b052..77b0210 100644 --- a/WebhookDump.csproj +++ b/WebhookDump.csproj @@ -23,7 +23,7 @@ all - + all