summaryrefslogtreecommitdiff
path: root/app/Libraries/Background.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Libraries/Background.php')
-rw-r--r--app/Libraries/Background.php29
1 files changed, 26 insertions, 3 deletions
diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php
index 8cfe9e1..b23e519 100644
--- a/app/Libraries/Background.php
+++ b/app/Libraries/Background.php
@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Jikan\MyAnimeList\MalClient;
+use Jikan\Helper\Constants;
use App\Libraries\AnimeSchedule;
use App\Libraries\AnimeSeason;
@@ -217,17 +218,18 @@ class Background {
}
public function saveEnhancementForAll() {
- $anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->where('synopsis', '')->get();
+ #$anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->where('synopsis', '')->get();
+ $anime_all = Anime::where('synopsis', '')->get();
foreach( $anime_all as $anime ) {
$this->addEnhancementToAnime($anime);
sleep(1);
}
}
- public function saveTopAnime() {
+ public function saveTopAnime($startpage = 1, $endpage = 10) {
$jikan = new MalClient;
- for ( $page = 1; $page <= 10; $page++) {
+ for ( $page = $startpage; $page <= $endpage; $page++) {
$topAnime = $jikan->getTopAnime(
(new \Jikan\Request\Top\TopAnimeRequest($page))
);
@@ -243,6 +245,27 @@ class Background {
}
+ public function saveTopAnimeByPopularity($startpage = 1, $endpage = 10) {
+ $jikan = new MalClient;
+
+ for ( $page = $startpage; $page <= $endpage; $page++) {
+ $topAnime = $jikan->getTopAnime(
+ (new \Jikan\Request\Top\TopAnimeRequest(
+ $page,
+ Constants::TOP_BY_POPULARITY))
+ );
+
+ sleep(5);
+ foreach ( $topAnime as $anime) {
+ if ( $this->saveAnime($anime) ) {
+ echo "saveTopAnime: Saved (" . $anime->getMalId() . ")\n";
+ }
+ sleep(5);
+ }
+ }
+
+ }
+
private function saveAnime($entry, $caller = "saveAnime") {
if ( Anime::where('mal_id', $entry->getMalID())->exists() ) {
/**