Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve video title filters #1667

Merged
merged 1 commit into from
Mar 27, 2024
Merged

Conversation

Serial-ATA
Copy link
Contributor

This adds more filters for cleanupName that I have encountered in the wild.

Notably: (video version), [HQ], (live), [4K]

@ArjixWasTaken
Copy link
Contributor

Instead of matching all the surrounding whitespace (well, at least the whitespace on the left) in every regex pattern, wouldn't it be better to not match it and after the replacements to trim + remove duplicate whitespaces?

Like

let title = "Rap God [live]"
title = title.replace("[live]", "") // on phone, not gonna write regex

title = title.replace(/\s+/g, ' ').trim()

?

@Serial-ATA
Copy link
Contributor Author

I don't think it makes that much of a difference (?), but since multiple patterns check the end of the string, you'd have to trim the string after each match anyway.

@ArjixWasTaken
Copy link
Contributor

I don't think it makes that much of a difference (?), but since multiple patterns check the end of the string, you'd have to trim the string after each match anyway.

Sounds like an issue with the patterns to me

@Serial-ATA
Copy link
Contributor Author

In the context of a microbench I can't get better performance out of a whitespace replacement + trim at the end, but that could very well be my mistake.

If you can make a benchmark between the two solutions, please do share it. Regardless though, this is only done when the song changes (likely every few minutes). So, it's not very performance critical in the first place.

@ArjixWasTaken
Copy link
Contributor

True

@JellyBrick JellyBrick added the enhancement New feature or request label Jan 30, 2024
@JellyBrick JellyBrick self-requested a review February 3, 2024 09:24
@Serial-ATA
Copy link
Contributor Author

Hey @JellyBrick, any update on this? This would be really helpful with the scrobbler plugin. I have to make manual edits right now with a bunch of junk suffixes falling through.

@JellyBrick JellyBrick merged commit 3718053 into th-ch:master Mar 27, 2024
6 checks passed
iryis pushed a commit to iryis/th-ch-ytmusic that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants