Repository navigation
fix: Improve music keyword detection for playback speed - #4352
Merged
ImprovedTube2 merged 2 commits intoSep 23, 2026
Merged
ImprovedTube2 merged 2 commits into
ImprovedTube2 merged 2 commits into
Conversation
Member
|
hi! @hkzo |
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.
Summary
This PR improves the music content detection logic to accurately identify videos and apply the appropriate playback speed adjustments.
Changes
match(/,/).musicIdentifiersTagsOnlyregex to match exact keywords without relying on surrounding comma delimiters.testSongDurationto perform a proper type check usingtypeof.Why
match(/,/)to count keywords, which only matched the first comma and failed to determine the total count. This resulted in an incorrect denominator and inflated music match ratios.musicIdentifiersTagsOnlyregex required specific surrounding delimiters (commas) and had loose boundary definitions, making it brittle, position-dependent, and prone to matching unintended strings.testSongDurationreturnsundefinedfor video durations outside of the expected ranges (e.g., < 45s or > 720s), but the logic incorrectly compared the result against the string'undefined'instead of verifying the typeundefined.This PR addresses these issues by normalizing input data and ensuring the implementation aligns with the original design intent for ratio calculations. The threshold of 0.08 remains unchanged.
Impact of Accurate Keyword Counting
Because the keyword ratio is now calculated using the actual count of valid keyword tags, videos with numerous general tags but only a few music-related tags may see a lower overall music match score.
Testing
keywordsAmountof 0 to avoid potential division-by-zero errors.testSongDurationaccurately validates the return value.Notes
AI assistance was used solely for translating this PR description. All code changes and tests were performed manually.