jikan-me / jikan

Unofficial MyAnimeList PHP+REST API which provides functions other than the official API

Home Page:https://jikan.moe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getAnimeEpisodes returns null in the URL field of some episodes.

abitofevrything opened this issue · comments

The docs indicate that the url field in each element of the array returned by getAnimeEpisodes is not nullable, yet it returns null for some anime.

To reproduce:

curl https://api.jikan.moe/v4/anime/51815/episodes (Kubo-san wa Mob wo Yurusanai).

{"pagination":{"last_visible_page":1,"has_next_page":true},"data":[{"mal_id":1,"url":null,"title":"The Heroine Girl and the Invisible Boy","title_japanese":"\u30d2\u30ed\u30a4\u30f3\u5973\u5b50\u3068\u30e2\u30d6\u7537\u5b50","title_romanji":"Heroine Joshi to Mob Danshi\u00a0","aired":"2023-01-10T00:00:00+00:00","score":4.3,"filler":false,"recap":false,"forum_url":"https:\/\/myanimelist.net\/forum\/?topicid=2069094"},{"mal_id":2,"url":null,"title":"Bad Luck and Home Visit","title_japanese":"\u30cf\u30fc\u30c9\u30e9\u30c3\u30af\u3068\u81ea\u5b85\u8a2a\u554f","title_romanji":"Hard Luck to Jitaku Houmon\u00a0","aired":"2023-01-17T00:00:00+00:00","score":4.4,"filler":false,"recap":false,"forum_url":"https:\/\/myanimelist.net\/forum\/?topicid=2070677"},{"mal_id":3,"url":null,"title":"The Nobody's Gift","title_japanese":"\u51e1\u8005\u306e\u8d08\u308a\u7269","title_romanji":null,"aired":"2023-01-24T00:00:00+00:00","score":4.5,"filler":false,"recap":false,"forum_url":"https:\/\/myanimelist.net\/forum\/?topicid=2072137"},{"mal_id":4,"url":null,"title":"Red Heart and Sender","title_japanese":"\u8d64\u3044\u30cf\u30fc\u30c8\u3068\u9001\u308a\u4e3b","title_romanji":"Akai Heart to Okurinushi\u00a0","aired":"2023-01-31T00:00:00+00:00","score":4.4,"filler":false,"recap":false,"forum_url":"https:\/\/myanimelist.net\/forum\/?topicid=2073620"}]}

Note that requesting the episode directly does return a valid URL:

$ curl https://api.jikan.moe/v4/anime/51815/episodes/1
{"data":{"mal_id":1,"url":"https:\/\/myanimelist.net\/anime\/51815\/Kubo-san_wa_Mob_wo_Yurusanai\/episode\/1","title":"The Heroine Girl and the Invisible Boy","title_japanese":"\u30d2\u30ed\u30a4\u30f3\u5973\u5b50\u3068\u30e2\u30d6\u7537\u5b50","title_romanji":"Heroine Joshi to Mob Danshi","duration":1420,"aired":"2023-01-10T00:00:00+09:00","filler":false,"recap":false,"synopsis":null}}

I thought at first this is an API error, but it's not. Transferring it back to Jikan repo.

@abitofevrything The url is null because the list items on MAL doesn't have episode video urls yet, and the parser is looking for those instead of the episode-url bit:
https://github.com/jikan-me/jikan/blob/master/src/Model/Anime/EpisodeListItem.php#L82
This will be populated for sure in the future.

Not sure if this is a bug. @irfan-dahir you might know more about this.

Well, the docs should at least be updated to reflect this. It's also very easy to generate the URL, just adding /episode/<number> to the anime URL so we could fall back to that if no episode URL is found.

Updated the docs of the API: jikan-me/jikan-rest@7120c1e#diff-feaa1d5b3b940a08f5552b0863a27844827f26e11244ef8d9adb3b80a843bccfL206
It will be part of the next release of the API.