summaryrefslogtreecommitdiff
path: root/app/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'app/Libraries')
-rw-r--r--app/Libraries/Background.php17
1 files changed, 9 insertions, 8 deletions
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);