diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/AnimeStats.php | 17 | ||||
| -rw-r--r-- | app/Libraries/Background.php | 7 |
2 files changed, 17 insertions, 7 deletions
diff --git a/app/AnimeStats.php b/app/AnimeStats.php index a4f3396..9b9b850 100644 --- a/app/AnimeStats.php +++ b/app/AnimeStats.php @@ -94,9 +94,16 @@ class AnimeStats extends Model { $this->season_name= $season_name; } - $animeInfo = $jikan->getAnime( - (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) - ); + try { + $animeInfo = $jikan->getAnime( + (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) + ); + } catch (\Exception $e) { + 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(); @@ -112,7 +119,7 @@ class AnimeStats extends Model { echo "Error requesting AnimeStats for " . $this->mal_id ."\n"; echo "Message: " . $e->getMessage(); echo "\n\n"; - return; + return false; } $this->watching = $animeStats->getWatching(); @@ -173,6 +180,8 @@ class AnimeStats extends Model { } else { $this->score_10 = 0; } + + return true; } public function anime() { diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php index 2d63a3e..5334480 100644 --- a/app/Libraries/Background.php +++ b/app/Libraries/Background.php @@ -149,9 +149,10 @@ class Background { echo "Getting stats for " . $entry->mal_id ."\n"; $animeStats = new AnimeStats(); - $animeStats->fill( $entry->mal_id ); - - $animeStats->save(); + if ( $animeStats->fill($entry->mal_id) ) { + # Only save if no error + $animeStats->save(); + } # sleep to avoid 403 sleep(5); |
