Skip to content

Fix captions: use player API instead of broken get_transcript endpoint - #261

Open
powellnorma wants to merge 4 commits into
user234683:masterfrom
powellnorma:fix-captions
Open

Fix captions: use player API instead of broken get_transcript endpoint#261
powellnorma wants to merge 4 commits into
user234683:masterfrom
powellnorma:fix-captions

Conversation

@powellnorma

Copy link
Copy Markdown

YouTube's get_transcript innertube API now requires PO tokens, returning FAILED_PRECONDITION (400). Switch to fetching captions via the android player API (baseUrl from captionTracks), which still works without PO tokens.

  • Add get_working_caption_url() to fetch caption URLs via android player API
  • Default use_innertube_for_captions to False
  • Auto-fallback from innertube to player API if innertube fails
  • Update android client to 19.29.37, web client to 2.20260114.08.00
  • Fix call_youtube_api to handle optional API key, use prettyPrint=false
  • Fix innertube_caption.py protobuf encoding and error handling

Fixes #257

YouTube's get_transcript innertube API now requires PO tokens,
returning FAILED_PRECONDITION (400). Switch to fetching captions
via the android player API (baseUrl from captionTracks), which
still works without PO tokens.

- Add get_working_caption_url() to fetch caption URLs via android player API
- Default use_innertube_for_captions to False
- Auto-fallback from innertube to player API if innertube fails
- Update android client to 19.29.37, web client to 2.20260114.08.00
- Fix call_youtube_api to handle optional API key, use prettyPrint=false
- Fix innertube_caption.py protobuf encoding and error handling
- Use android client instead of web for get_transcript API calls
- Add multi_deep_get fallback paths for both web and android response formats
  (updateEngagementPanelAction vs elementsCommand, runs vs elementsAttributedString)
@powellnorma

Copy link
Copy Markdown
Author

@ndgsa Thanks for the suggestion! Switched to android client and added multi_deep_get for both response formats - so it handles both the updateEngagementPanelAction and elementsCommand paths now. This way it should work regardless of which response structure YouTube returns. See commit 19471b1.

YouTube has blocked the android client (400 Bad Request). yt-dlp has
also confirmed this and removed android from their defaults.

- Switch player API fallback from android to android_vr (Oculus Quest 3)
- Update android_vr client version from 1.60.19 to 1.71.26
- Default use_innertube_for_captions to False (get_transcript is dead on all clients)
- Add try/except around player API call in get_working_caption_url
@user234683

Copy link
Copy Markdown
Owner

This looks very similar to #240. I had some comments there that would also apply to this one

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.

Transcript is not loading

2 participants