summaryrefslogtreecommitdiff
path: root/app/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'app/Libraries')
-rw-r--r--app/Libraries/Background.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php
index 91d9d75..3f8ea5c 100644
--- a/app/Libraries/Background.php
+++ b/app/Libraries/Background.php
@@ -156,7 +156,7 @@ class Background {
$animeStats = new AnimeStats();
- if ( $animeStats->fill($entry->mal_id) ) {
+ if ( $animeStats->fillStats($entry->mal_id) ) {
# Only save if no error
$animeStats->save();
$counter++;
@@ -242,6 +242,7 @@ class Background {
$enhancement = $anime->getEnhancementFromAnilist();
} catch( \Exception $e ) {
echo "addEnhancementToAnime: Getting Data from Anilist failed for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n";
+ echo $e->getMessage() ."\n";
return;
}
if ( "" == $enhancement ) {
@@ -251,6 +252,15 @@ class Background {
$update = array();
if ( ! is_null( $enhancement->description ) ) {
$update["synopsis"] = str_replace('<br>', '%%br%%', $enhancement->description);
+
+ /*
+ * Fix broken html
+ */
+ $tidy = new \Tidy();
+ $tidy->parseString($update["synopsis"], [ 'show-body-only' => true ], 'utf8');
+ $tidy->cleanRepair();
+ $update["synopsis"] = $tidy;
+
}
if ( ! is_null( $enhancement->hashtag ) ) {
$update["hashtag"] = $enhancement->hashtag;
@@ -269,14 +279,18 @@ class Background {
DB::table('anime')
->where('mal_id', $anime->mal_id)
->update( $update );
+
+ sleep(1);
}
public function saveEnhancementForAll() {
#$anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->where('synopsis', '')->get();
$anime_all = Anime::where('synopsis', '')->orWhereNull('duration')->get();
+ #$anime_all = Anime::where('synopsis', '!=', '')->get();
foreach( $anime_all as $anime ) {
$this->addEnhancementToAnime($anime);
- sleep(1);
+ #usleep(500000); # 0.5s
+ sleep(5);
}
}
@@ -335,7 +349,7 @@ class Background {
/**
* Sleep to avoid 403 by MAL.
*/
- $anime->fill( $entry->getMalID() );
+ $anime->fillStats( $entry->getMalID() );
if ( "" == $anime->url ) {
echo $caller . ": url is empty for: " . $entry->getMalId() . "\n";
@@ -401,7 +415,7 @@ class Background {
foreach( $anime as $entry ) {
$count++;
$fill = new Anime;
- $fill->fill( $entry->mal_id, $skip_if_unpopular=false ); # check every anime we have, even with less than 10k members
+ $fill->fillStats( $entry->mal_id, $skip_if_unpopular=false ); # check every anime we have, even with less than 10k members
if ( $fill->image_url != $entry->image_url ) {
echo "Image URL (" . $entry->mal_id . ", " . $entry->title_pref . ") changed from " . $entry->image_url . " to " . $fill->image_url . "\n";