From 38ad5415db862e24da03ee194ef723540f9848a6 Mon Sep 17 00:00:00 2001 From: horus Date: Thu, 5 Mar 2020 22:24:28 +0100 Subject: Basic usage implemented. --- app/Anime.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'app/Anime.php') diff --git a/app/Anime.php b/app/Anime.php index 7971430..9e6ac58 100644 --- a/app/Anime.php +++ b/app/Anime.php @@ -25,35 +25,41 @@ class Anime extends Model { 'title_pref', 'anime_type', 'broadcasted', - 'episodes' + 'episodes', + 'is_airing' ]; public function __construct() { } - public function fill( $id, $parse_info = true ) { + public function fill( $id ) { $this->mal_id = $id; - if ( $parse_info ) { - $jikan = new Malclient; + $jikan = new Malclient; + try { $this->animeInfo = $jikan->getAnime( (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) ); + } catch (\Exception $e) { + echo "Problem requesting AnimeInfo for (" . $anime->mal_id . ") continue\n"; + echo $e->getMessage(); + echo "\n\n"; + } - $this->url = $this->animeInfo->GetUrl(); - $this->image_url = $this->animeInfo->getImageUrl(); + $this->url = $this->animeInfo->GetUrl(); + $this->image_url = $this->animeInfo->getImageUrl(); - $this->title_eng = $this->animeInfo->getTitleEnglish(); - $this->title_rom = $this->animeInfo->getTitle(); - $this->title_nat = $this->animeInfo->getTitleJapanese(); - $this->title_pref = $this->animeInfo->getTitle(); + $this->title_eng = $this->animeInfo->getTitleEnglish(); + $this->title_rom = $this->animeInfo->getTitle(); + $this->title_nat = $this->animeInfo->getTitleJapanese(); + $this->title_pref = $this->animeInfo->getTitle(); - $this->anime_type = $this->animeInfo->getType(); - $this->broadcasted = $this->animeInfo->getBroadcast(); + $this->anime_type = $this->animeInfo->getType(); + $this->broadcasted = $this->animeInfo->getBroadcast(); - $this->episodes = $this->animeInfo->getEpisodes(); - } + $this->episodes = $this->animeInfo->getEpisodes(); + $this->is_airing = $this->animeInfo->isAiring(); } public function getStats() { -- cgit v1.2.3