fix: fix tencent search

This commit is contained in:
cxfksword
2026-05-30 18:05:50 +08:00
parent 24f276fa7f
commit 3b356f0af4
3 changed files with 66 additions and 16 deletions

View File

@@ -13,6 +13,8 @@ public class TencentSearchData
{
[JsonPropertyName("normalList")]
public TencentSearchBox NormalList { get; set; }
[JsonPropertyName("areaBoxList")]
public List<TencentSearchBox> AreaBoxList { get; set; }
}
public class TencentSearchBox

View File

@@ -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<TencentEpisode> 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; }
}

View File

@@ -65,28 +65,68 @@ public class TencentApi : AbstractApi
var result = new List<TencentVideo>();
var searchResult = await response.Content.ReadFromJsonAsync<TencentSearchResult>(_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<List<TencentVideo>>(cacheKey, result, expiredOption);
return result;