-
Notifications
You must be signed in to change notification settings - Fork 438
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
[YouTube] Update iOS client and add visitor data to InnerTube requests #1262
Conversation
Does it only work with visitor data for you? What happens only with an updated IOS client but no visitor data? Btw the visitor data could also be extracted from |
I just tested in NewPipe and it works, thank you! |
Yes, it only works with the visitor data cookie. I first tried updating the client version and the issue was still there. You can extract the visitor data cookie from YouTube, but that requires an extra request. I have been using random visitor data cookies in my own YouTube client for a few months now and they work without issues. |
Okay. I closed my PR, let's go with visitor data. Cool stuff, thank you.
I know I wanted to leave this info here just in case as a backup plan. If the format of the visitor data changes your solution can break. Fetching it from YT ensures it will always follow the official and up-to-date format. I'm not sure what is better but the random generator seems okay for now.
just out of curiosity why do you refer to it as "cookie"? |
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ProtoBuilder.java
Outdated
Show resolved
Hide resolved
YouTube does store the visitor data as a cookie (__Secure-YEC), but probably also in local storage so it can be sent as an API parameter by the player code. It fulfills the role of an unique session ID so I call it a cookie. I dont know if there are better terms for it. |
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
28a9bdf
to
65d888f
Compare
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
@@ -222,28 +223,28 @@ private YoutubeParsingHelper() { | |||
private static final String IOS_DEVICE_MODEL = "iPhone16,2"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The device used here is an iPhone 15 Pro Max but the comments are incorrectly update to "iPhone 16".
Either change/revert the comments to iPhone 15 Pro Max or update the device model to "iPhone17,2" to match the iPhone 16 Pro Max.
The mapping can be found here: https://gist.github.com/adamawolf/3048717
or: https://theapplewiki.com/wiki/Firmware/iPhone/18.x#iPhone_16_Pro_Max
This is a nearly verbatim copy of [1], for now the code is pretty rough and I'm not even sure that this data should be passed for all requests but it does seem to unblock the iOS client for now. [1] TeamNewPipe/NewPipeExtractor#1262
} | ||
} | ||
} catch (final IOException e) { | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: It may be better to use UncheckedIOException
here since it's more specific
This might be also relevant for the rest of the file ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor things that I would change.
But anyway nice PR!
@@ -1256,6 +1275,7 @@ public static JsonBuilder<JsonObject> prepareIosMobileJsonBuilder( | |||
.value("platform", "MOBILE") | |||
.value("osName", "iOS") | |||
.value("osVersion", IOS_OS_VERSION) | |||
.value("visitorData", randomVisitorData(contentCountry)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be the same as vData
?
Maybe add a short comment into the code that documents this
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
public class ProtoBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some documentation would be nice, e.g. what this class does
This is a nearly verbatim copy of [1], for now the code is pretty rough and I'm not even sure that this data should be passed for all requests but it does seem to unblock the iOS client for now. [1] TeamNewPipe/NewPipeExtractor#1262
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
…youtube/YoutubeParsingHelper.java Co-authored-by: Stypox <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you a lot! I am going to release a new version right now, as I don't have too much time in the next few days and don't want to keep users waiting. So I'm merging this PR despite there being some finishing touches to do still.
@Theta-Dev please open a new PR to address the review comments. And @litetex @gechoto please continue the review in the other PR that is going to be opened. And thanks for reviewing :-)
Thank you 💯 for fast-tracking this |
@Theta-Dev friendly reminder to open a follow-up PR to add more documentation |
This is a nearly verbatim copy of [1], for now the code is pretty rough and I'm not even sure that this data should be passed for all requests but it does seem to unblock the iOS client for now. [1] TeamNewPipe/NewPipeExtractor#1262
AFAIK using random visitor data IDs with the iOS client stopped working this week, so I guess we can remove the visitor data generator again. |
I have fixed the issue with the iOS client returning invalid responses
Apparently the only issue with the iOS client is that we were not sending it visitor data cookies. Since the visitor data cookies are just protobuf objects with a random ID, timestamp and country code, they can be randomly generated and dont need to be fetched from YouTube.
Fixes #1259
Fixes TeamNewPipe/NewPipe#11934