mal_id = $id; if ( 54591 == $this->mal_id ) { return true; } $jikan = new Malclient; if ( 0 == $season_year || "" == $season_name ) { $season = $jikan->getSeasonal( (new \Jikan\Request\Seasonal\SeasonalRequest( )) ); $this->season_year = $season->seasonYear; $this->season_name= $season->seasonName; } else { $this->season_year = $season_year; $this->season_name= $season_name; } try { $animeInfo = $jikan->getAnime( (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) ); } catch (\Exception $e) { // Anime 54591 got deleted on MAL if ( 54591 != $this->mal_id ) { echo "Error requesting AnimeInfo for " . $this->mal_id ."\n"; echo "Message: " . $e->getMessage(); echo "\n\n"; } return false; } $this->score = $animeInfo->getScore(); $this->scored_by = $animeInfo->getScoredBy(); $this->rank = $animeInfo->getRank(); $this->popularity = $animeInfo->getPopularity(); $this->members = $animeInfo->getMembers(); $this->favorites = $animeInfo->getFavorites(); try { $animeStats = $jikan->getAnimeStats( (new \Jikan\Request\Anime\AnimeStatsRequest( $this->mal_id )) ); } catch (\Exception $e) { echo "Error requesting AnimeStats for " . $this->mal_id ."\n"; echo "Message: " . $e->getMessage(); echo "\n\n"; return false; } $this->watching = $animeStats->getWatching(); $this->completed = $animeStats->getCompleted(); $this->onhold = $animeStats->getOnHold(); $this->dropped = $animeStats->getDropped(); $this->plan_to_watch = $animeStats->getPlanToWatch(); $scores = $animeStats->getScores(); if ( isset($scores[1] )) { $this->score_1 = $scores[1]->getVotes(); } else { $this->score_1 = 0; } if ( isset($scores[2]) ) { $this->score_2 = $scores[2]->getVotes(); } else { $this->score_2 = 0; } if ( isset($scores[3]) ) { $this->score_3 = $scores[3]->getVotes(); } else { $this->score_3 = 0; } if ( isset($scores[4]) ) { $this->score_4 = $scores[4]->getVotes(); } else { $this->score_4 = 0; } if ( isset($scores[5]) ) { $this->score_5 = $scores[5]->getVotes(); } else { $this->score_5 = 0; } if ( isset($scores[6]) ) { $this->score_6 = $scores[6]->getVotes(); } else { $this->score_6 = 0; } if ( isset($scores[7]) ) { $this->score_7 = $scores[7]->getVotes(); } else { $this->score_7 = 0; } if ( isset($scores[8]) ) { $this->score_8 = $scores[8]->getVotes(); } else { $this->score_8 = 0; } if ( isset($scores[9]) ) { $this->score_9 = $scores[9]->getVotes(); } else { $this->score_9 = 0; } if ( isset($scores[10]) ) { $this->score_10 = $scores[10]->getVotes(); } else { $this->score_10 = 0; } return true; } public function anime() { return $this->belongsTo('App\Anime', 'mal_id', 'mal_id'); } }