From 3b356f0af4ab9da89ecaec012014f485ca615a8f Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Sat, 30 May 2026 18:05:50 +0800 Subject: [PATCH] fix: fix tencent search --- .../Tencent/Entity/TencentSearchResult.cs | 2 + .../Scrapers/Tencent/Entity/TencentVideo.cs | 8 +++ .../Scrapers/Tencent/TencentApi.cs | 72 ++++++++++++++----- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentSearchResult.cs b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentSearchResult.cs index 60ca852..066548a 100644 --- a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentSearchResult.cs +++ b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentSearchResult.cs @@ -13,6 +13,8 @@ public class TencentSearchData { [JsonPropertyName("normalList")] public TencentSearchBox NormalList { get; set; } + [JsonPropertyName("areaBoxList")] + public List AreaBoxList { get; set; } } public class TencentSearchBox diff --git a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentVideo.cs b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentVideo.cs index 05c87e9..e217437 100644 --- a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentVideo.cs +++ b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/Entity/TencentVideo.cs @@ -31,6 +31,8 @@ public class TencentVideo public int? Year { get; set; } [JsonPropertyName("subjectDoc")] public TencentSubjectDoc SubjectDoc { get; set; } + [JsonPropertyName("videoDoc")] + public TencentVideoDoc VideoDoc { get; set; } [JsonIgnore] public List EpisodeList { get; set; } } @@ -40,3 +42,9 @@ public class TencentSubjectDoc [JsonPropertyName("videoNum")] public int VideoNum { get; set; } } + +public class TencentVideoDoc +{ + [JsonPropertyName("uploader")] + public string Uploader { get; set; } +} diff --git a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/TencentApi.cs b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/TencentApi.cs index f4ca7e7..978492f 100644 --- a/Jellyfin.Plugin.Danmu/Scrapers/Tencent/TencentApi.cs +++ b/Jellyfin.Plugin.Danmu/Scrapers/Tencent/TencentApi.cs @@ -65,28 +65,68 @@ public class TencentApi : AbstractApi var result = new List(); var searchResult = await response.Content.ReadFromJsonAsync(_jsonOptions, cancellationToken).ConfigureAwait(false); - if (searchResult != null && searchResult.Data != null && searchResult.Data.NormalList != null && searchResult.Data.NormalList.ItemList != null) + if (searchResult != null && searchResult.Data != null ) { - foreach (var item in searchResult.Data.NormalList.ItemList) + if (searchResult.Data.NormalList != null && searchResult.Data.NormalList.ItemList != null) { - if (item.VideoInfo == null) + foreach (var item in searchResult.Data.NormalList.ItemList) { - continue; - } - if (item.VideoInfo.Year == null || item.VideoInfo.Year == 0) - { - continue; - } - if (item.VideoInfo.Title.Distance(keyword) <= 0) - { - continue; - } + if (item.VideoInfo == null || item.VideoInfo.VideoDoc == null) + { + continue; + } + if (item.VideoInfo.VideoDoc != null) + { + continue; + } + if (item.VideoInfo.Year == null || item.VideoInfo.Year == 0) + { + continue; + } + if (item.VideoInfo.Title.Distance(keyword) <= 0) + { + continue; + } - var video = item.VideoInfo; - video.Id = item.Doc.Id; - result.Add(video); + var video = item.VideoInfo; + video.Id = item.Doc.Id; + result.Add(video); + } + } + if (searchResult.Data.AreaBoxList != null) + { + foreach (var areaBox in searchResult.Data.AreaBoxList) + { + if (areaBox.ItemList != null) + { + foreach (var item in areaBox.ItemList) + { + if (item.VideoInfo == null) + { + continue; + } + if (item.VideoInfo.VideoDoc != null) + { + continue; + } + if (item.VideoInfo.Year == null || item.VideoInfo.Year == 0) + { + continue; + } + if (item.VideoInfo.Title.Distance(keyword) <= 0) + { + continue; + } + + var video = item.VideoInfo; + video.Id = item.Doc.Id; + result.Add(video); + } + } + } } } + _memoryCache.Set>(cacheKey, result, expiredOption); return result;