feature/oembed-detection-fix #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/oembed-detection-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Two separate improvements bundled in one branch:
README& project cleanupmain→feature/*(droppeddevelop)just prnow detects the current branch automaticallydetect_shortwas swallowing exceptions, so the error tracker inapp.pynever fired onYouTube failures
The previous approach fetched
youtube.com/shorts/{id}and checked if the final redirect URL still contained/shorts/.This is broken for EU deployments!
YouTube redirects all requests to
consent.youtube.comfirst, so/shorts/is never found and every video gets cached asis_short=0.Replaced with the
oEmbed API:Shorts are portrait (height > width); regular videos are landscape. Bypasses consent walls entirely.
Edge case handling:
ValueErrorso the error tracker fires and the video passes through uncachedAfter deploying
Clear the poisoned video cache (all entries are wrong
is_short=0):The previous approach fetched youtube.com/shorts/{id} and checked if the final redirect URL still contained /shorts/. This breaks for EU deployments because YouTube redirects all requests to consent.youtube.com first, so /shorts/ is never found and every video is cached as is_short=0. The oEmbed API bypasses consent entirely and returns reliable portrait/ landscape dimensions. Shorts are portrait (height > width); regular videos are landscape. Behaviour: - Non-200 response (age-restricted, 404, etc.): return False without caching - Missing dimensions in response: raise ValueError so the error tracker fires and the video passes through uncached (better to let a Short slip through than break a feed permanently) - Network exceptions: propagate as before so error tracker fires After deploying, clear the poisoned video cache: docker exec yt-shorts-proxy python -c " import sqlite3; conn = sqlite3.connect('/data/cache.db') conn.execute('DELETE FROM videos'); conn.commit(); print('cache cleared') "