library: parallelize standby media fetching and add search-position tiebreak - #1049
Open
LWWZH wants to merge 2 commits into
Open
library: parallelize standby media fetching and add search-position tiebreak#1049LWWZH wants to merge 2 commits into
LWWZH wants to merge 2 commits into
Conversation
Member
|
这里面有个问题,假设总共3个source,每个 source 都匹配到2个候选歌曲。本来的排序是 那么以前的逻辑,会按照分数去看是否有合适的播放资源,也就是先看 a1 和 b1 是否有可播放资源。然后再看其它的。 现在这样改了之后,相当于不会关注它的分数了。 |
Contributor
Author
|
@cosven |
LWWZH
force-pushed
the
feat/standby-search-improvement
branch
from
July 2, 2026 01:19
0aad26f to
f005822
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #902
Changes
1. Parallel media fetching in
a_list_song_standby_v2The standby search's second phase (fetching media URLs for qualified candidates) was serial: each candidate was tried one-by-one with
awaitinside aforloop. This is now parallel — all candidates' media are fetched concurrently viaasyncio.gather, then results are collected in score-sorted order.Candidates are already bounded by
max_per_source=2per provider, so the total number of concurrent requests stays manageable.2. Search-result position as tiebreaker
When two candidates have the same match score, the one that appears earlier in its provider's search results is now preferred. This leverages the platform's own ranking as a relevance signal, since providers typically return the most relevant results first.
The sort key is
(-score, result_position)— highest score first, then lowest position first.Testing
Two new tests in
tests/library/test_library.py:test_library_a_list_song_standby_v2_fetches_media_in_parallel— verifies multiple providers' candidates get media fetched concurrentlytest_library_a_list_song_standby_v2_uses_search_position_as_tiebreak— verifies same-score candidates are ordered by their position in provider search resultsAll 13 library/standby tests pass.