Initial Commit
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s

This commit is contained in:
2026-08-28 22:55:32 +10:00
parent d8d4ecbe8a
commit f00405ed24
16 changed files with 1008 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Models\Story;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature('direct:scrape-stories')]
#[Description('Scrape Instagram story content via Playwright')]
class ScrapeStories extends RunsPlaywrightScript
{
protected string $script = 'scrape-story-content.spec.js';
protected function afterRun(): void
{
$path = base_path('playwright/output/scrape-stories.json');
if (! file_exists($path)) {
$this->warn('No output file found — nothing to upsert.');
return;
}
$items = json_decode(file_get_contents($path), true);
foreach ($items as $item) {
Story::updateOrCreate(
['id' => $item['id']],
[
'user_id' => $item['user_id'],
'username' => $item['username'],
'profile_pic_url' => $item['profile_pic_url'],
'code' => $item['code'],
'is_video' => $item['is_video'],
'taken_at' => $item['taken_at'],
'expiring_at' => $item['expiring_at'],
'image_url' => $item['image_url'],
'video_url' => $item['video_url'],
'accessibility_caption' => $item['accessibility_caption'],
'muted' => $item['muted'],
]
);
}
$this->info('Upserted ' . count($items) . ' story items.');
}
}