diff options
| author | horus | 2020-07-23 19:02:44 +0200 |
|---|---|---|
| committer | horus | 2020-07-23 19:02:44 +0200 |
| commit | c4b821cc89cd80cb23f52c5d38e90f6defb2e835 (patch) | |
| tree | 5e37961812fabaf198016e7c6887eb8a5925741d /app | |
| parent | 675109d7344a222de5cf8bb843b1f7ec2942b69f (diff) | |
| download | senpai-c4b821cc89cd80cb23f52c5d38e90f6defb2e835.tar.gz | |
Replaced is_airing with airing_status.
Diffstat (limited to 'app')
| -rw-r--r-- | app/Anime.php | 5 | ||||
| -rw-r--r-- | app/Console/Kernel.php | 11 | ||||
| -rw-r--r-- | app/Http/Controllers/AnimeController.php | 2 | ||||
| -rw-r--r-- | app/Libraries/Background.php | 17 |
4 files changed, 21 insertions, 14 deletions
diff --git a/app/Anime.php b/app/Anime.php index 4c72910..6f7f0c1 100644 --- a/app/Anime.php +++ b/app/Anime.php @@ -26,7 +26,8 @@ class Anime extends Model { 'anime_type', 'broadcasted', 'episodes', - 'is_airing' + 'is_airing', + 'airing_status' ]; public function __construct() { @@ -72,6 +73,8 @@ class Anime extends Model { $this->episodes = $animeInfo->getEpisodes(); $this->is_airing = $animeInfo->isAiring(); + + $this->airing_status = getAiringStatusCode($animeInfo->getStatus()); } public function getStats() { diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f7dc4eb..6f99217 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -69,13 +69,16 @@ class Kernel extends ConsoleKernel })->weeklyOn(1, '15:30'); #})->everyMinute(); -/* + /* $schedule->call( function(){ $background = new Background(); - $anime = Anime::where('mal_id', 40591)->get()->first(); - $background->saveAiring( $anime ); + #$background->checkIfIsAiring(); + $background->saveSeason(); + #$anime = Anime::where('mal_id', 40591)->get()->first(); + #$background->saveAiring( $anime ); })->everyMinute(); -*/ + #})->twiceDaily(9, 23); + */ } /** diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php index 2f46cd5..461b583 100644 --- a/app/Http/Controllers/AnimeController.php +++ b/app/Http/Controllers/AnimeController.php @@ -97,7 +97,7 @@ class AnimeController extends Controller { $most_surprising_anime = $most_surprising_anime->simplePaginate(10); #$anime = $anime->setTable('anime'); - $anime = $anime->where('is_airing', 1); + $anime = $anime->where('airing_status', env('ANIME_IS_AIRING')); $anime = $anime->orderBy('watching', 'desc'); $anime = $anime->orderBy('members', 'desc'); $anime = $anime->orderBy('score_today', 'desc'); diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php index db9e42f..2d7c7fb 100644 --- a/app/Libraries/Background.php +++ b/app/Libraries/Background.php @@ -19,7 +19,7 @@ use Eluceo\iCal\Component\Event; class Background { public function saveAiring(Anime $anime) { - if ( ! $anime->is_airing ) { + if ( $anime->airing_status != env("ANIME_IS_AIRING") ) { echo "saveAiring: Anime (" . $anime->mal_id . ") is not airing. Skipping.\n"; return; } @@ -105,7 +105,7 @@ class Background { } public function saveAiringForAll() { - $anime_all = Anime::where('is_airing', true)->get(); + $anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->get(); foreach( $anime_all as $anime ) { $this->saveAiring($anime); sleep(1); @@ -140,7 +140,8 @@ class Background { * Sleep to avoid 403 by MAL. */ sleep(10); - $anime->fill( $entry->getMalID(), $is_airing=true ); + #$anime->fill( $entry->getMalID(), $is_airing=true ); + $anime->fill( $entry->getMalID() ); if ( "" == $anime->url ) { echo "saveSeason: url is empty for: " . $entry->getMalId() . "\n"; @@ -182,7 +183,7 @@ class Background { public function checkIfIsAiring() { $jikan = new Malclient; - foreach( Anime::where('airing_status', '=', 4)->get() as $anime) { + foreach( Anime::where('airing_status', '!=', env('ANIME_FINISHED_AIRING'))->get() as $anime) { try { $animeInfo = $jikan->getAnime( (new \Jikan\Request\Anime\AnimeRequest( $anime->mal_id )) @@ -197,12 +198,12 @@ class Background { $airing_status = getAiringStatusCode( $animeInfo->getStatus() ); - if ( ! $animeInfo->isAiring() ) { + if ( $anime->airing_status != $airing_status ) { DB::table('anime') ->where('mal_id', $anime->mal_id) - ->update(['is_airing' => false, 'airing_status' => $airing_status]); + ->update(['airing_status' => $airing_status]); } - sleep(10); + sleep(5); } } @@ -239,7 +240,7 @@ class Background { } public function saveEnhancementForAll() { - $anime_all = Anime::where('is_airing', true)->where('synopsis', '')->get(); + $anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->where('synopsis', '')->get(); foreach( $anime_all as $anime ) { $this->addEnhancementToAnime($anime); sleep(1); |
