29 lines
702 B
PHP
29 lines
702 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Story;
|
|
use App\Services\StoryMediaCacher;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('stories:cache-media')]
|
|
#[Description('Download and locally cache any story media still pointing at Instagram\'s CDN')]
|
|
class CacheStoryMedia extends Command
|
|
{
|
|
public function handle(StoryMediaCacher $mediaCacher): int
|
|
{
|
|
$count = 0;
|
|
|
|
foreach (Story::query()->cursor() as $story) {
|
|
$mediaCacher->cache($story);
|
|
$count++;
|
|
}
|
|
|
|
$this->info("Checked {$count} stories.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|