Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
在综合搜索结果中移除非视频搜索结果 (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy committed Jul 5, 2022
1 parent 8280e57 commit 0318df6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Adapter/Adapter.Implementation/SearchAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using Bili.Adapter.Interfaces;
using Bili.Models.App.Constants;
using Bili.Models.BiliBili;
using Bili.Models.Data.Search;
using Bili.Models.Data.Video;
Expand Down Expand Up @@ -45,7 +46,7 @@ public ComprehensiveSet ConvertToComprehensiveSet(ComprehensiveSearchResultRespo
var isEnd = response.ItemList == null;
var videos = isEnd
? new List<VideoInformation>()
: response.ItemList.Select(p => _videoAdapter.ConvertToVideoInformation(p)).ToList();
: response.ItemList.Where(p => p.Goto == ServiceConstants.Av).Select(p => _videoAdapter.ConvertToVideoInformation(p)).ToList();
var videoSet = new SearchSet<VideoInformation>(videos, isEnd);

return new ComprehensiveSet(videoSet, metaList);
Expand Down
3 changes: 2 additions & 1 deletion src/Adapter/Adapter.Implementation/VideoAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ public VideoInformation ConvertToVideoInformation(Relate relatedVideo)
/// <inheritdoc/>
public VideoInformation ConvertToVideoInformation(VideoSearchItem searchVideo)
{
var title = _textToolkit.ConvertToTraditionalChineseIfNeeded(searchVideo.Title);
var title = Regex.Replace(searchVideo.Title, @"<[^<>]+>", string.Empty);
title = _textToolkit.ConvertToTraditionalChineseIfNeeded(title);
var id = searchVideo.Parameter;
var duration = string.IsNullOrEmpty(searchVideo.Duration)
? 0
Expand Down
3 changes: 2 additions & 1 deletion src/Lib/Lib.Implementation/SearchProvider/SearchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ public async Task<ComprehensiveSet> GetComprehensiveSearchResultAsync(string key
var request = await _httpProvider.GetRequestMessageAsync(HttpMethod.Get, Models.App.Constants.ApiConstants.Search.ComprehensiveSearch, queryParameters, Models.Enums.RequestClientType.IOS);
var response = await _httpProvider.SendAsync(request);
var result = await _httpProvider.ParseAsync<ServerResponse<ComprehensiveSearchResultResponse>>(response);
var data = _searchAdapter.ConvertToComprehensiveSet(result.Data);
_comprehensivePageNumber++;
return _searchAdapter.ConvertToComprehensiveSet(result.Data);
return data;
}

/// <inheritdoc/>
Expand Down
7 changes: 7 additions & 0 deletions src/Models/Models.Data/Community/Partition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ namespace Bili.Models.Data.Community
/// </summary>
public sealed class Partition
{
/// <summary>
/// Initializes a new instance of the <see cref="Partition"/> class.
/// </summary>
public Partition()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Partition"/> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private async Task SelectModuleAsync(SearchModuleItemViewModel vm)
TryClear(CurrentFilters);
await FakeLoadingAsync();
CurrentModule = vm;
ClearCurrentModule();
await GetDataAsync();
}

Expand Down

0 comments on commit 0318df6

Please sign in to comment.