Skip to content

fix(route/imdb): fetch charts from GraphQL API#22682

Open
JaggerH wants to merge 1 commit into
DIYgod:masterfrom
JaggerH:feature-imdb-chart
Open

fix(route/imdb): fetch charts from GraphQL API#22682
JaggerH wants to merge 1 commit into
DIYgod:masterfrom
JaggerH:feature-imdb-chart

Conversation

@JaggerH

@JaggerH JaggerH commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Involved Issue / 该 PR 相关 Issue

Close #

Example for the Proposed Route(s) / 路由地址示例

/imdb/chart/top
/imdb/chart/moviemeter
/imdb/chart/toptv
/imdb/chart/tvmeter

New RSS Route Checklist / 新 RSS 路由检查表

  • New Route / 新的路由
  • Anti-bot or rate limit / 反爬/频率限制
    • If yes, do your code reflect this sign? / 如果有, 是否有对应的措施?
  • Date and time / 日期和时间
    • Parsed / 可以解析
    • Correct time zone / 时区正确
  • New package added / 添加了新的包
  • Puppeteer

Note / 说明

/imdb/chart/:chart currently returns HTTP 503. The route fetches
https://www.imdb.com/chart/:chart/ and parses script#__NEXT_DATA__, but
IMDb no longer ships chart data in the page HTML — a plain server-side fetch
now hits an AWS WAF JavaScript challenge (HTTP 202) with no __NEXT_DATA__
blob, so JSON.parse throws (SyntaxError: Unexpected end of JSON input).

This PR fetches the same data from IMDb's public GraphQL API
(https://api.graphql.imdb.com/) via the chartTitles query, which is not
behind the WAF challenge and needs no auth. The four charts map to the
ChartTitleType enum:

chart ChartTitleType
top TOP_RATED_MOVIES
moviemeter MOST_POPULAR_MOVIES
toptv TOP_RATED_TV_SHOWS
tvmeter MOST_POPULAR_TV_SHOWS

Genre display names now come directly from titleGenres.genres[].genre.text,
so the old connection-level facet lookup is dropped. The item shape
(title / description with poster + rating + plot / link / category) is
unchanged. No date is exposed because the charts provide no reliable per-item
timestamp. Verified locally: all four charts return items; e.g. moviemeter #1
"Obsession (2025)" with rating 8/10 and genres Horror/Romance/Thriller.

IMDb no longer ships chart data in the page HTML — the plain server-side
fetch of /chart/:chart now hits an AWS WAF JavaScript challenge (HTTP 202),
so `script#__NEXT_DATA__` is absent and `JSON.parse` throws, returning 503.

Fetch the same data from IMDb's public GraphQL API (api.graphql.imdb.com)
via the `chartTitles` query instead. The four charts map to the
ChartTitleType enum (TOP_RATED_MOVIES / MOST_POPULAR_MOVIES /
TOP_RATED_TV_SHOWS / MOST_POPULAR_TV_SHOWS). Genre display names now come
straight from `titleGenres.genres[].genre.text`, so the old facet lookup is
dropped. Item shape (title / description / link / category) is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the route label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant