fix: reliable thumbnail resolution in hqify with async sddefault upgrade - #400
Open
KrX3D wants to merge 3 commits into
Open
fix: reliable thumbnail resolution in hqify with async sddefault upgrade#400KrX3D wants to merge 3 commits into
KrX3D wants to merge 3 commits into
Conversation
hqdefault is guaranteed for every video; sddefault is not generated for older uploads and returns 404, causing a grey placeholder. Set hqdefault immediately, then HEAD-check sddefault and upgrade the thumbnail reference in-place if the CDN confirms it exists.
ice-fly
approved these changes
Mar 23, 2026
ice-fly
left a comment
There was a problem hiding this comment.
Execllent fix, code comments, and contribution!
sync: upstream reisxd/TizenTube main (30 commits)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
hqifywas unconditionally setting thumbnails tosddefault.jpg(640×480), but YouTube only generates
sddefaultfor videos uploadedafter a certain point. Older videos return a 404 for that filename,
which the TV browser renders as a grey placeholder instead of the
actual thumbnail.
Switching blindly to
hqdefault(480×360) fixes the grey box butsacrifices resolution for videos where
sddefaultdoes exist.Solution
Two-phase approach:
hqdefaultimmediately — guaranteed to exist for everyvideo ever uploaded, so no grey boxes under any circumstance.
sddefault— if the CDN responds 200,upgrade the same
thumbnails[0]reference in-place to thehigher resolution version.
Because
thumbsholds a live reference into the item object and theTV layout pipeline runs after multiple JS microtasks, the HEAD response
(against the same CDN already warm from page load) typically resolves
before the renderer reads the thumbnail, so most videos get the
640×480 version with no visible flash or fallback.
Also adds an early
continueguard for tiles with no existingthumbnail URL (some home page tiles are lazy-loaded and arrive with
an empty thumbnails array), preventing a crash in those cases.
Additionally, the original thumbnail URL from YouTube's JSON contains a
long query string (visible as
?sqp=...&rs=...on the URL). This is aCDN signature tied to the exact filename it was issued for — copying it
onto a different filename causes a signature mismatch and the CDN returns
the grey placeholder regardless of whether the file actually exists.
Dropping the query string entirely avoids this; plain filename URLs like
hqdefault.jpgandsddefault.jpgwork without any signing.Before:

After:
