Fix web throttling because of double deciphering #3759
Merged
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.
Fix web throttling because of double deciphering
Pull Request Type
Related issue
closes #3457
partially #3738 (will create a separate pull request for the comments)
Description
Finally figured out why DASH was getting throttled but audio only and the legacy formats were fine. Took multiple weeks and stabs in the dark but we finally solved it.
The cause was us deciphering the formats and overwriting the URL in the
Format
objects, to avoid having to decipher them in lots of places around FreeTube (e.g. downloads, audio only, legacy). Unfortunately when we generated the DASH manifest with toDash, YouTube.js deciphered the already deciphered formats again, causing the n-param to be correct everywhere but the DASH manifest.I don't why we were completely fine without any throttling for months before that became an issue, all I can think is that YouTube made a change that resulted in the double deciphering becoming a problem.
As the web client is fine again, I'm removing the extra fetching of the android formats, so that we don't make excess requests. If we end up needing them again in the future, they can always be added back quite easily.
Thank you very much to @AudricV and @LuanRT for their help and putting up with me while we tried to figure out the issue! 🤗
Testing
Play videos on the local API without proxying with the DASH formats enabled. Additionally test some age restricted videos like this one mentioned in the issue https://youtu.be/rrSnnhe53ks or the videos in this playlist: https://www.youtube.com/playlist?list=PLze6c8Dxpjv4eaemhVXYLURZt3Pcrddw5