diff options
| author | horus | 2020-07-23 17:15:11 +0200 |
|---|---|---|
| committer | horus | 2020-07-23 17:15:11 +0200 |
| commit | 675109d7344a222de5cf8bb843b1f7ec2942b69f (patch) | |
| tree | 9cbad6c83108649fc1be3bff7c1aa0c555c79c7d /app | |
| parent | 88c61db3a9c41886a74fa0d1c3e6fc71774e6e52 (diff) | |
| download | senpai-675109d7344a222de5cf8bb843b1f7ec2942b69f.tar.gz | |
Bugfix. Correctly detects airing anime.
Diffstat (limited to 'app')
| -rw-r--r-- | app/Libraries/Background.php | 8 | ||||
| -rw-r--r-- | app/helpers.php | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php index 920c866..db9e42f 100644 --- a/app/Libraries/Background.php +++ b/app/Libraries/Background.php @@ -182,7 +182,7 @@ class Background { public function checkIfIsAiring() { $jikan = new Malclient; - foreach( Anime::where('is_airing', true)->get() as $anime) { + foreach( Anime::where('airing_status', '=', 4)->get() as $anime) { try { $animeInfo = $jikan->getAnime( (new \Jikan\Request\Anime\AnimeRequest( $anime->mal_id )) @@ -191,14 +191,18 @@ class Background { echo "checkIfIsAiring: Problem requesting AnimeInfo for (" . $anime->mal_id . ") continue\n"; echo $e->getMessage(); echo "\n\n"; + sleep(10); continue; } + + $airing_status = getAiringStatusCode( $animeInfo->getStatus() ); if ( ! $animeInfo->isAiring() ) { DB::table('anime') ->where('mal_id', $anime->mal_id) - ->update(['is_airing' => false]); + ->update(['is_airing' => false, 'airing_status' => $airing_status]); } + sleep(10); } } diff --git a/app/helpers.php b/app/helpers.php index 0953a56..7ac1fd6 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -58,3 +58,11 @@ function printScoreData($score_array) { return $return; } + +function getAiringStatusCode($airing_status) { + $status = DB::select("SELECT id FROM airing_status WHERE status = ?", array($airing_status)); + if ( empty($status) ) { + return 4; + } + return $status[0]->id; +} |
