magnum357i / myanimelist-api

Api for MyAnimeList. It contains: pages of info, search and widget
MIT License
9 stars 2 forks source link

Addition of Opening & Endings in Anime Page #2

Closed Sher1234 closed 5 years ago

Sher1234 commented 5 years ago

I have gone through the code & want to propose the addition of openings & endings in the \myanimelist\Page\Anime

protected function _openings() {
    $key = 'openings';
    if (isset(static::$data[$key])) return static::$data[$key];
    if (!$this->request()::isSent()) return FALSE;
    $data = $this->request()::match('<div class="theme-songs js-theme-songs opnening">(.*?)<br></div>', '<br>');
    $data = explode('<br>', $data);
    if ($data) return static::setValue($key, $data);
    return FALSE;
}

protected function _endings() {
    $key = 'endings';
    if (isset(static::$data[$key])) return static::$data[$key];
    if (!$this->request()::isSent()) return FALSE;
    $data = $this->request()::match('<div class="theme-songs js-theme-songs ending">(.*?)<br></div>', '<br>');
    $data = explode('<br>', $data);
    if ($data) return static::setValue($key, $data);
    return FALSE;
}
Sher1234 commented 5 years ago

Also the addition on _titlesysnonmys() in \myanimelist\Page\Manga

magnum357i commented 5 years ago

I'll add what you said in the new version. I'm handling issues reported in codaacy right now. I'll release it in a few days.

Sher1234 commented 5 years ago

A minor improvement in the above methods

if (count($data) == 1 && $data[0] == "") return FALSE;
return static::setValue($key, $data);

It earlier provides an array with single empty string for no opening & endings Add this at the end of both the functions.

Output:

"openings": [
    "#01: \"Mune ga Dokidoki (胸がドキドキ)\" by the High-Lows (eps 1-30)",
    "#02: \"Feel Your Heart\" by Velvet Garden (eps 31-52)",
    "#03: \"Nazo (謎)\" by Miho Komatsu (小松未歩) (eps 53-96)",
    "#04: \"Unmei no Roulette Mawashite (運命のルーレット廻して)\" by ZARD (eps 97-123)",
    "#05: \"Truth\" by Two-Mix (eps 124-142)",
    "#06: \"Girigiri Chop (ギリギリchop)\" by B&#039;z (eps 143-167)",
    "#07: \"Mysterious Eyes\" by Garnet Crow (eps 168-204)"
]
magnum357i commented 5 years ago

Added. Thanks for help. 💯

(Just made a more detailed output in songs)

You can open a different ticket if you have another request. See you there. 😃