downloads: youtube card open button → YouTube link (was opening a random show)

the open-show button rendered for youtube cards too; the click ran parseInt on the
youtube video id → ids starting with a digit became a small library id (e.g. 3 →
'3rd Rock from the Sun'), others became NaN → broken link. youtube cards now render a
real YouTube link for that button; movie/show/episode keep the open-detail button.
regression test pins the youtube branch.
This commit is contained in:
BoulderBadgeDad 2026-06-26 13:19:47 -07:00
parent b916e6a2f3
commit 3f924812da
2 changed files with 20 additions and 3 deletions

View file

@ -50,6 +50,17 @@ def test_drawer_renders_the_rich_tmdb_fields():
assert "trailer_url" in _JS and "providers" in _JS
def test_youtube_open_button_links_to_youtube_not_a_show_page():
# regression: the open-show button ran parseInt(youtube_id) → opened a random library
# show (e.g. id 3) or a broken link. youtube cards must open a YouTube link instead.
open_block = _JS.split("var openBtn")[1].split("var stateBtn")[0]
assert "dlType(d.kind) === 'youtube'" in open_block
assert "youtube.com/watch?v=" in open_block
# the data-vdpg-open (open-show) path must NOT be taken for youtube
assert "data-vdpg-open" in open_block # still there for movie/show
assert open_block.index("'youtube'") < open_block.index("data-vdpg-open") # youtube branch first
def test_drawer_has_episode_youtube_and_availability_blocks():
assert "vdpg-dr-ytthumb" in _JS # youtube big thumbnail header
assert "vdpg-dr-ep" in _JS and "vdpg-dr-epstill" in _JS # episode still + block

View file

@ -154,9 +154,15 @@
var lab = q('label'); if (lab.textContent !== labelTxt) lab.textContent = labelTxt;
var act = q('actions');
var openBtn = d.media_id ? '<button class="vdpg-open" type="button" data-vdpg-open="' + esc(d.media_id) +
'" data-kind="' + esc(d.kind || 'movie') + '" data-source="' + esc(d.media_source || 'library') +
'" title="Open ' + (d.kind === 'movie' ? 'movie' : 'show') + ' page">' + OPEN_SVG + '</button>' : '';
// youtube videos aren't TMDB titles — the open button links to YouTube, not a show page
// (parseInt on a video id was opening a random library show / a broken link).
var openBtn = !d.media_id ? ''
: (dlType(d.kind) === 'youtube'
? '<a class="vdpg-open" href="https://www.youtube.com/watch?v=' + encodeURIComponent(d.media_id) +
'" target="_blank" rel="noopener" title="Open on YouTube">' + OPEN_SVG + '</a>'
: '<button class="vdpg-open" type="button" data-vdpg-open="' + esc(d.media_id) +
'" data-kind="' + esc(d.kind || 'movie') + '" data-source="' + esc(d.media_source || 'library') +
'" title="Open ' + (d.kind === 'movie' ? 'movie' : 'show') + ' page">' + OPEN_SVG + '</button>');
var stateBtn = active
? '<button class="adl-row-cancel" type="button" data-vdpg-cancel="' + d.id + '" title="Cancel">' + X_SVG + '</button>'
: isFail(d.status)