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

[Debug] print requests as curl commands #5025

Closed
wants to merge 1 commit into from

Conversation

iBicha
Copy link
Contributor

@iBicha iBicha commented Oct 26, 2024

This makes invidious prints requests it makes as curl commands. For example, when visting the trending page, the following curl command would be printed:

curl -X POST 'https://www.youtube.com/youtubei/v1/browse?prettyPrint=false' -H 'Content-Type: application/json; charset=UTF-8' -H 'x-goog-api-format-version: 2' -H 'x-youtube-client-name: 1' -H 'x-youtube-client-version: 2.20240814.00.00' -H 'Host: www.youtube.com' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36' -H 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,;q=0.7' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/*;q=0.8' -H 'Accept-Language: en-us,en;q=0.5' -H 'Cookie: ; CONSENT=PENDING+644' -d '{"browseId":"FEtrending","context":{"client":{"hl":"en","gl":"US","clientName":"WEB","clientVersion":"2.20240814.00.00","clientScreen":"WATCH_FULL_SCREEN","osName":"Windows","osVersion":"10.0","platform":"DESKTOP"}}}'

This is useful for a few things:

  • Understanding what Invidious is doing with Innertube
  • Can easily copy the command and run in a terminal, dump response to a file
  • Easier to iterate on requests that have issues

@iBicha iBicha requested a review from a team as a code owner October 26, 2024 15:20
@iBicha iBicha requested review from syeopite and removed request for a team October 26, 2024 15:20
@unixfox
Copy link
Member

unixfox commented Oct 26, 2024

Not really fond in doing that since we already have a set of tools to make it easier to talk to YouTube API: https://github.com/iv-org/youtube-utils

@iBicha
Copy link
Contributor Author

iBicha commented Oct 26, 2024

Not really fond in doing that since we already have a set of tools to make it easier to talk to YouTube API: https://github.com/iv-org/youtube-utils

This is what I prefer (and use) to debug issues - I prefer to see exactly what Invidious is doing and when etc
I don't feel strongly about merging this PR, just sharing what I find productive for myself

@Fijxu
Copy link
Contributor

Fijxu commented Nov 1, 2024

@iBicha I recommend you to use proxychains with mitmproxy. That is what I use to debug requests on Invidious like I did here: #5033

@unixfox
Copy link
Member

unixfox commented Nov 1, 2024

@iBicha I recommend you to use proxychains with mitmproxy. That is what I use to debug requests on Invidious like I did here: #5033

Now you can use the http_proxy feature directly with mitmproxy:

http_proxy:
user:
password:
host:
port:

@iBicha
Copy link
Contributor Author

iBicha commented Nov 1, 2024

Closing the PR since the purpose was to share my approach.
I like copying a curl command, run and dump response into a json file, then iterate on the command while diffing the response. Tweak header and payload to get innertube to return different things. This is a simple approach, doesn't require other tools, nor hooking up a proxy. Different tools for different things I guess.
Feel free to repurpose this if it's ever useful

@iBicha iBicha closed this Nov 1, 2024
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.

3 participants