Episode names: render MAL titles on the episode grid
anidb's episodes API has no names (id/number/filler only), but the
Jikan call we already make for intro timings carries them (title +
title_japanese). _parse_intros now keeps one entry per episode with
title and optional start/length (entries are never null anymore).
Client: attachEpNames() reuses the introCache promise, stamps
epsList[i].name, re-renders; buttons show the name (3-line clamp) +
full tooltip. Jikan down => no names, no error (same graceful
degradation as the skip-intro button).
Verified headless: Jujutsu Kaisen S1 24/24 buttons named
('E1 | Ryomen Sukuna' ...); S2 (Jikan 504 at the time) rendered
gracefully without names. 17/17 API tests.
This commit is contained in:
1 parent
d60524815f
commit
343628a2e3
4 files changed
+35
-11
No files matched your search
+10
-8
@@ -301,17 +301,19 @@ def _search_count(user):
|
||||
def test_parse_intros():
|
||||
from server.upstream import _parse_intros
|
||||
out = _parse_intros([
|
||||
{"intro": {"start": 95, "length": 60}},
|
||||
{"intro": {"start": 95, "length": 60}, "title": "Ryomen Sukuna"},
|
||||
{"intro": {"start": 0, "length": 0}}, # MAL "no intro" marker
|
||||
{"intro": None},
|
||||
{"intro": None, "title": "Named, no timing"},
|
||||
{},
|
||||
])
|
||||
assert out == [
|
||||
{"start": 95, "length": 60},
|
||||
{"start": 0, "length": 0},
|
||||
None,
|
||||
None,
|
||||
{"title": "Ryomen Sukuna", "start": 95, "length": 60},
|
||||
{"title": None, "start": 0, "length": 0},
|
||||
{"title": "Named, no timing"},
|
||||
{"title": None},
|
||||
]
|
||||
# setupIntro relies on `t.length` being absent (falsy) when no timing
|
||||
assert "start" not in out[2]
|
||||
|
||||
|
||||
def test_intros_parses_jikan_shapes():
|
||||
@@ -330,8 +332,8 @@ def test_intros_parses_jikan_shapes():
|
||||
u._CACHE.clear()
|
||||
u._get = lambda url: R() # stub the network
|
||||
assert u._intros(92573) == [
|
||||
{"start": 111, "length": 77},
|
||||
{"start": 0, "length": 0},
|
||||
{"title": "Episode 1", "start": 111, "length": 77},
|
||||
{"title": "Episode 2", "start": 0, "length": 0},
|
||||
]
|
||||
# wrapped shape still works
|
||||
class W:
|
||||
|
||||
Reference in new issue
Block a user