Skip to content

Resolve subtitles through base_url#733

Closed
kekulta wants to merge 1 commit intokillergerbah:mainfrom
kekulta:po-token
Closed

Resolve subtitles through base_url#733
kekulta wants to merge 1 commit intokillergerbah:mainfrom
kekulta:po-token

Conversation

@kekulta
Copy link
Copy Markdown

@kekulta kekulta commented Jun 14, 2025

This PR is inspired by #609.
The original PR appears outdated and unlikely to be completed, so here's a new implementation.

With huge help from the YouTube.js maintainer, I figured out how to retrieve poToken and resolve subtitles directly.
I hardcoded &tlang=en rn just to check that auto-translation works. If this approach is ok, I will clean it up and make second PR with support to auto-translated subs.

This is a draft (very messy!). If we agree this approach works, I'll clean it up.

I'm not a web developer, so this is essentially my first interaction with TypeScript.

I hope I didn't reinvent the wheel here 😄

image

@kekulta kekulta marked this pull request as draft June 14, 2025 05:29
@killergerbah
Copy link
Copy Markdown
Owner

@kekulta Thank you, this is incredible work. If I'm understanding the change correctly, the POT is cached in session storage and can be decoded. I think this approach will work great.

I only have a few things to add before you clean things up:

  • As you already commented in your change, some parts of the POT implementation like the session storage keys might be unstable. If possible it would be good to keep your integration as resistant to change as possible.
  • If for some reason the POT extraction fails, it would good if we could still fallback to the existing InnerTube solution.

Some other minor comments which I think you're already aware of:

  • base64 functions can be reused, instead of rewriting them in a few places.
  • The SRT conversion can be done using the SrtParser already being used with the InnerTube transcription.
  • There's no need to try to support legacy browsers - asbplayer will never run in a browser that isn't modern-ish.

@killergerbah
Copy link
Copy Markdown
Owner

One other thing - the original idea to support YT's machine-translated tracks will need the user to specify their target language somewhere. Naturally, I think this would be another setting. But let me know if you had other ideas.

@killergerbah
Copy link
Copy Markdown
Owner

Thanks again for this contribution. I used your PR as a starting point to integrate POT decoding as a fallback method for fetching YT subs. In particular, the POT seems to provide the only reliable way to fetch subs for members-only videos.

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