8000 Read anime card type and start date from the card's own fields by irfan-dahir · Pull Request #656 · jikan-me/jikan · GitHub
[go: up one dir, main page]

Skip to content

Read anime card type and start date from the card's own fields - #656

Merged
irfan-dahir merged 2 commits into
masterfrom
v5/anime-card-hidden-fields
Oct 14, 2026
Merged

irfan-dahir merged 2 commits into
masterfrom
v5/anime-card-hidden-fields

Conversation

@irfan-dahir
Copy link
Copy Markdown
Collaborator

Needs jikan-me/jikan-fixtures#15 merged first (snapshots).

Follow-up to #636's "dead branches in AnimeCardParser". I traced which branch each of the 1,370 anime cards on the recorded genre, producer and seasonal pages takes, and every branch is used, so there is no dead code. The check did turn up a bug and missing data instead.

Every anime card carries two fields that we weren't reading:

  • a js-anime-type-N class, numbered the same as the search filter (1 = TV … 9 = TV Special, 0 = unknown);
  • a hidden .js-start_date of YYYYMMDD, with 00 for unknown parts (20270000, 00000000).

AnimeCardParser now reads them first and keeps the visible text as the fallback.

Problem Cards in the recorded pages
A year-only date ("2027") was read as the time 20:27 today 123 "later" seasonal, 2 schedule
Schedule cards got the weekday heading ("Friday", "Other") as their type every schedule card
Producer cards: type and start date always null 666
Genre cards: start date always null 200
Seasonal TV Specials reported their section heading, "Special" 2 (now "TV Special", as getAnime() says)

How partial dates are handled: an unknown month or day falls on the 1st (midnight in Japan, converted to UTC), as "Oct 2027" already did. 00000000 gives null.

Tests: AnimeCardHiddenFieldsTest checks:

  • the type map against the type genre and seasonal cards show (over 600 cards);
  • that every card with a type class reports that type;
  • every recorded start date;
  • the full, month-only, year-only and unknown date formats;
  • the fallback, where a bare visible year is no longer read as a time.

Snapshot changes are limited to type and airingStart. There's a changelog entry under Fixed.

🤖 Generated with Claude Code

Every anime card carries a js-anime-type-N class (numbered like the search
filter) and a hidden js-start_date ("YYYYMMDD", 00 for unknown parts).
AnimeCardParser now reads them first:
- year-only dates ("2027") were read as 20:27 today; now 1 January of that year
- schedule cards got the weekday heading ("Friday") as their type
- producer cards had no type or date; genre cards had no date
- seasonal TV Specials read "TV Special", not their "Special" section heading
The visible text stays as the fallback. AnimeCardHiddenFieldsTest checks the
type map against what genre and seasonal cards show, and every date format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PR's mutation run flagged no-op code: casts and isset() around the type map
(the regex now accepts only 1-9), trim() and anchors on the hidden date (text()
already trims; it is always 8 digits), trim() after cleanse(). The fallback for
cards without the hidden date is now tested with "Oct 2027" and a full date with
"(JST)", not only a bare year.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@irfan-dahir
irfan-dahir merged commit c054488 into master Oct 14, 2026
7 checks passed
CrafterSama pushed a commit to CrafterSama/jikan that referenced this pull request Oct 27, 2026
Moves the accumulated Unreleased entries under "v5.0.0-beta.2 — 2026-10-15" with a
short summary, and leaves an empty Unreleased heading. Also moves the anime-card
entry from jikan-me#656, which landed in the format template's example "Fixed" section,
into the release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant

0