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

add more parameter to look a lot like official youtube client #4851

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

unixfox
Copy link
Member

@unixfox unixfox commented Aug 15, 2024

Taken from a request done by youtube.js: https://github.com/LuanRT/YouTube.js and I tried to add as much new parameters as possible.

example_yt_request_youtubejs.txt

We are missing:

       "mainAppWebInfo"     => {
          "graftUrl"                  => "https://www.youtube.com",
          "isWebNativeShareAvailable" => true,
          "pwaInstallabilityStatus"   => "PWA_INSTALLABILITY_STATUS_UNKNOWN",
          "webDisplayMode"            => "WEB_DISPLAY_MODE_BROWSER",
        },

inside client_context = { but I can't get my head around the compiler issue:

Done checking player dependencies, now compiling Invidious...
Showing last frame. Use --error-trace for full trace.

In src/invidious/yt_backend/youtube_api.cr:320:33

 320 | "mainAppWebInfo"     => {
                               ^----------
Error: expected argument #2 to 'Hash(String, Int64 | String)#[]=' to be (Int64 | String), not Hash(String, Bool | String)

Overloads are:
 - Hash(K, V)#[]=(key : K, value : V)

Other parameters we are missing:

  • timeZone: in youtube.js this is dynamically generated from the actual timezone but I don't know if we should or just set a default one
  • utcOffsetMinutes: same as above
  • visitorData: this one is tricky because it requires to generate a visitordata from scratch
  • remoteHost: we will have to fetch the public IP of the server at the start; not sure how
  • "configInfo"."appInstallData": like visitordata, it's an ID

Remarks:

  • Some parameters do not make sense in the context of the ANDROID client but I don't think this will do any harm like the size for screenHeightPoints or memoryTotalKbytes
  • I required useragent to be passed because youtube is expecting it now on all the requests whatever the client name

@unixfox unixfox requested a review from a team as a code owner August 15, 2024 16:30
@unixfox unixfox requested review from SamantazFox and removed request for a team August 15, 2024 16:30
@unixfox unixfox force-pushed the more-info-looklike-youtube-client branch from 2f815b6 to 6482b1b Compare August 15, 2024 16:31
@unixfox unixfox force-pushed the more-info-looklike-youtube-client branch 4 times, most recently from 78f8b80 to f565b81 Compare August 15, 2024 16:35
@unixfox unixfox force-pushed the more-info-looklike-youtube-client branch from f565b81 to ada232a Compare August 15, 2024 16:42
@unixfox unixfox force-pushed the more-info-looklike-youtube-client branch from ada232a to ddd232a Compare August 15, 2024 16:44
@SamantazFox
Copy link
Member

Other parameters we are missing:

* timeZone: in youtube.js this is dynamically generated from the actual timezone but I don't know if we should or just set a default one
* utcOffsetMinutes: same as above
* remoteHost: we will have to fetch the public IP of the server at the start; not sure >     * "configInfo"."appInstallData": like visitordata, it's an ID

As far as I know, these can be safely omitted. On some browsers with stronger privacy/adblocking features (like Tor), I've often seen these empty.

Some parameters do not make sense in the context of the ANDROID client but I don't think this will do any harm like the size for screenHeightPoints or memoryTotalKbytes

Maybe it's time to split the context logic by client, like NewPipe does?

@unixfox
Copy link
Member Author

unixfox commented Aug 15, 2024

Other parameters we are missing:

* timeZone: in youtube.js this is dynamically generated from the actual timezone but I don't know if we should or just set a default one
* utcOffsetMinutes: same as above
* remoteHost: we will have to fetch the public IP of the server at the start; not sure >     * "configInfo"."appInstallData": like visitordata, it's an ID

As far as I know, these can be safely omitted. On some browsers with stronger privacy/adblocking features (like Tor), I've often seen these empty.

ok then we won't set those.

Some parameters do not make sense in the context of the ANDROID client but I don't think this will do any harm like the size for screenHeightPoints or memoryTotalKbytes

Maybe it's time to split the context logic by client, like NewPipe does?

Kinda don't have the time to do it today. I added all the parameters that I found on youtube.js because I have a separate proxy server for yewtu.be that exclusively use youtube.js and this one has never seen any issue about "watch on the latest version".

@unixfox
Copy link
Member Author

unixfox commented Aug 17, 2024

@SamantazFox can we merge into master branch?

browser_name: "Chrome",
browser_version: "128.0.0.0",
platform: "MOBILE",
user_agent: WEB_USER_AGENT,
Copy link
Member

Choose a reason for hiding this comment

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

We need a different UA here. "Windows NT 10.0" won't cut it I guess!

os_name: "Windows",
os_version: WINDOWS_VERSION,
browser_name: "Chrome",
browser_version: "128.0.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

can you put that in a constant at the top? It will be easier to maintain in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants