diff --git a/Jellyfin.Plugin.Danmu.Test/YoukuTest.cs b/Jellyfin.Plugin.Danmu.Test/YoukuTest.cs index 2f33c0c..4ed28a8 100644 --- a/Jellyfin.Plugin.Danmu.Test/YoukuTest.cs +++ b/Jellyfin.Plugin.Danmu.Test/YoukuTest.cs @@ -111,8 +111,8 @@ namespace Jellyfin.Plugin.Danmu.Test var item = new Season { - Name = "布莱切利四人组", - ProductionYear = 2012, + Name = "为有暗香来", + ProductionYear = 2023, }; var list = new List(); diff --git a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs index 50dcef7..26308ff 100644 --- a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs +++ b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs @@ -502,6 +502,8 @@ public class LibraryManagerEventsHelper : IDisposable continue; } var media = await scraper.GetMedia(season, mediaId); + var dd = media.Episodes.Count; + Console.WriteLine(dd); if (media == null) { _logger.LogInformation("[{0}]匹配成功,但获取不到视频信息. id: {1}", scraper.Name, mediaId); @@ -569,6 +571,7 @@ public class LibraryManagerEventsHelper : IDisposable } var media = await scraper.GetMedia(season, providerVal); + var dd = media.Episodes.Count; if (media == null) { _logger.LogInformation("[{0}]获取不到视频信息. ProviderId: {1}", scraper.Name, providerVal); diff --git a/Jellyfin.Plugin.Danmu/Scrapers/Youku/YoukuApi.cs b/Jellyfin.Plugin.Danmu/Scrapers/Youku/YoukuApi.cs index be9648d..70ffa60 100644 --- a/Jellyfin.Plugin.Danmu/Scrapers/Youku/YoukuApi.cs +++ b/Jellyfin.Plugin.Danmu/Scrapers/Youku/YoukuApi.cs @@ -110,8 +110,15 @@ public class YoukuApi : AbstractApi await this.LimitRequestFrequently(); + var cacheKey = $"video_{id}"; + var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) }; + if (this._memoryCache.TryGetValue(cacheKey, out var video)) + { + return video; + } + var pageSize = 20; - var video = await this.GetVideoEpisodesAsync(id, 1, pageSize, cancellationToken).ConfigureAwait(false); + video = await this.GetVideoEpisodesAsync(id, 1, pageSize, cancellationToken).ConfigureAwait(false); if (video != null) { var pageCount = (video.Total / pageSize) + (video.Total % pageSize > 0 ? 1 : 0); for (int pn = 2; pn <= pageCount; pn++) @@ -123,6 +130,7 @@ public class YoukuApi : AbstractApi } } + this._memoryCache.Set(cacheKey, video, expiredOption); return video; } @@ -142,13 +150,6 @@ public class YoukuApi : AbstractApi pageSize = 20; } - var cacheKey = $"video_episodes_{id}_{page}"; - var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) }; - if (this._memoryCache.TryGetValue(cacheKey, out var video)) - { - return video; - } - // 获取影片信息:https://openapi.youku.com/v2/shows/show.json?client_id=53e6cc67237fc59a&package=com.huawei.hwvplayer.youku&show_id=0b39c5b6569311e5b2ad // 获取影片剧集信息:https://openapi.youku.com/v2/shows/videos.json?client_id=53e6cc67237fc59a&package=com.huawei.hwvplayer.youku&ext=show&show_id=deea7e54c2594c489bfd var url = $"https://openapi.youku.com/v2/shows/videos.json?client_id=53e6cc67237fc59a&package=com.huawei.hwvplayer.youku&ext=show&show_id={id}&page={page}&count={pageSize}"; @@ -158,11 +159,8 @@ public class YoukuApi : AbstractApi var result = await response.Content.ReadFromJsonAsync(this._jsonOptions, cancellationToken).ConfigureAwait(false); if (result != null) { - this._memoryCache.Set(cacheKey, result, expiredOption); return result; } - - this._memoryCache.Set(cacheKey, null, expiredOption); return null; }