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

Youtube ID for trailer returns more than 11 characters

ToshY opened this issue · comments

commented

Problem

Anime returns youtube id with 12 characters instead of 11.

Reproduction

Example 16904 gives yhNzL20gNX0/ instead of yhNzL20gNX0.

Cause

While the original embed URL (with additional /) does work, the regex does not take this into account that it should only be 11 characters for the id.

See this line in Media.php.

Possible fixes

Correct match for id, possible solutions:

  1. Change regex part ([^\?&\"'>]+) to ([^\?&\"'>]{11})
  2. Change statement for $matches[1] ?? null to empty($matches[1]) === false ? substr($matches[1], 0, 11) : null
commented

@irfan-dahir I can create a PR for this if you prefer one of the solutions I provided.