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

Fix invalid yt url: signature tag name is not always "signature" #163

Merged
merged 2 commits into from
May 14, 2019

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented May 13, 2019

  • I carefully read the contribution guidelines and agree to them.
  • I did test the API against NewPipe.
  • [no breaking change] I agree to ASAP create a PULL request for NewPipe for making in compatible when I changed the api.

Thanks to @omarroth for the suggestion. For more info see #155 #162 TeamNewPipe/NewPipe#2337

This should fix many problems users keep having in the last few weeks: some videos in NewPipe don't load, at random. Invalid urls of those videos are then cached, and the app won't load them anymore until the cache is wiped. So even after this pr is merged, users would still have to manually wipe metadata from the app.

I tested the changes in the NewPipe app and it worked normally with all the videos I tried. I also added a Log instruction to have the url printed in the android logcat, and I saw that both types* of YouTube links work (one of them wouldn't have worked previously).

* One type (the one that has always worked) has "id" as the first url tag and signature tag "signature", the other (that created problems with the signature) has "expire" as the first url tag and signature tag "sig". Or at least it seems to be like this, to me.

Please merge this as soon as possible, since this issue is affecting many people and is very annoying :-) .

Fixes #162
Fixes (partially) #155
Fixes TeamNewPipe/NewPipe#2336
Fixes TeamNewPipe/NewPipe#2337
Fixes TeamNewPipe/NewPipe#2324
Fixes TeamNewPipe/NewPipe#2304
Fixes TeamNewPipe/NewPipe#2275
Probably also fixes TeamNewPipe/NewPipe#867
Probably also fixes TeamNewPipe/NewPipe#2297

@Stypox
Copy link
Member Author

Stypox commented May 13, 2019

The unsuccessful checks are due to a video, used to test comments, that is not available anymore.

@@ -888,7 +888,7 @@ private static String getVideoInfoUrl(final String id, final String sts) {
String streamUrl = tags.get("url");
// if video has a signature: decrypt it and add it to the url
if (tags.get("s") != null) {
streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode);
streamUrl = streamUrl + "&" + tags.get("sp") + "=" + decryptSignature(tags.get("s"), decryptionCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'd like to include this into 0.16.2 so we can get this fix out asap. Can we ensure that tags.get("sp") != null? If this is the case, we are good to go. Otherwise, I'd suggest to use streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode); as fallback if tags.get("sp") == null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll implement and test it this evening

@hp8wvvvgnj6asjm7
Copy link

asap pls!

If ever YouTube changes thing again (or uses old urls for some unknown reason), this prevents the extractor from crashing.
As suggested here: https://github.com/TeamNewPipe/NewPipeExtractor/pull/163/files/133cc032d9987130927e4c00e78e9fdbca1331dd#r283529811
@Stypox
Copy link
Member Author

Stypox commented May 14, 2019

Implemented and tested the suggestion from @TobiGr
Even if we can ensure that tags.get("sp") != null, there is no way to guarantee that YouTube will never remove the signature name from the url parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment