Skip to content

Commit

Permalink
Merge pull request #32 from ipkpjersi/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ipkpjersi authored Oct 20, 2024
2 parents b7b850c + 2424022 commit 31c344a
Show file tree
Hide file tree
Showing 78,855 changed files with 264,250 additions and 63,689 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions app/Console/Commands/DownloadAndImportAnimeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function handle(): void

// Download Anime Images
$this->info('Downloading anime images...');
//We could technically force this to re-download all anime images, except with our sleep timers it means it takes a week or more, so let's leave it off for now. The JSON anime database file is what sets the image URLs, which means it will only ever be delta updates (for existing anime), which means we probably don't really need to re-download all images. We could separately track if the anime image changes over time, which it likely will at some point, but this is likely largely unnecessary. It's always possible to start with anime images from scratch by running php artisan app:clear-anime-image-files and php artisan app:clear-anime-image-zip-files then php artisan app:download-anime-images --force to download all anime images from scratch.
//Artisan::call('app:download-anime-images', ['--force' => true], new ConsoleOutput);
Artisan::call('app:download-anime-images', [], new ConsoleOutput);

$this->info('All processes completed successfully.');
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/DownloadAnimeImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DownloadAnimeImages extends Command
*
* @var string
*/
protected $signature = 'app:download-anime-images';
protected $signature = 'app:download-anime-images {--force}';

/**
* The console command description.
Expand All @@ -35,7 +35,7 @@ public function handle(AnimeImageDownloadService $animeImageDownloadService): vo
$this->info($message);
};

$result = $animeImageDownloadService->downloadImages($logger);
$result = $animeImageDownloadService->downloadImages($logger, $this->option('force'));
$duration = round($result['duration'], 2);
$this->info("Downloaded {$result['successful']} out of {$result['totalImages']} images for {$result['total']} anime records successfully in {$duration} seconds.");
Log::channel('anime_import')->info("Downloaded {$result['successful']} out of {$result['totalImages']} images for {$result['total']} anime records successfully in {$duration} seconds.");
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/ImportAnimeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function handle(AnimeImportService $animeImportService): void
Log::channel('anime_import')->info('Anime database file not found or force download is enabled. Downloading from source...');
$fileData = file_get_contents('https://raw.githubusercontent.com/manami-project/anime-offline-database/master/anime-offline-database.json');
$directory = dirname($filePath);
//$this->info("Downloading anime import JSON file to $directory");
$this->info("Downloading anime import JSON file to $directory");
if (! file_exists($directory)) {
if (! mkdir($directory, 0755, true) && ! is_dir($directory)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory));
Expand Down
6 changes: 5 additions & 1 deletion app/Services/AnimeImageDownloadService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

class AnimeImageDownloadService
{
public function downloadImages($logger = null)
public function downloadImages($logger = null, $force = false)
{
if ($force) {
DB::table('anime')->update(['image_downloaded' => false]);
$logger && $logger("Force downloading: Resetting image_downloaded to false for all anime.");
}
$anime = DB::table('anime')
->whereNot('image_downloaded', '=', true)
->where(function ($query) {
Expand Down
Loading

0 comments on commit 31c344a

Please sign in to comment.