Initial commit: Animexe Laravel platform
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Anime;
|
||||
use App\Services\DeepSeekService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GenerateDiscoveryHooks extends Command
|
||||
{
|
||||
protected $signature = 'anime:generate-hooks {--limit=50 : Kaç anime işlensin} {--force : Zaten hook olanları da yeniden üret}';
|
||||
protected $description = 'Keşfet sayfası için anime hook metinlerini AI ile üret';
|
||||
|
||||
public function handle(DeepSeekService $ai): int
|
||||
{
|
||||
if (!$ai->isConfigured()) {
|
||||
$this->error('DeepSeek API anahtarı ayarlanmamış.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$limit = (int) $this->option('limit');
|
||||
$force = $this->option('force');
|
||||
|
||||
$query = Anime::where('is_published', true)->with('genres:id,name');
|
||||
if (!$force) {
|
||||
$query->whereNull('discovery_hook');
|
||||
}
|
||||
|
||||
$animes = $query->limit($limit)->get();
|
||||
|
||||
if ($animes->isEmpty()) {
|
||||
$this->info('Hook üretilecek anime bulunamadı.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->info("Toplam {$animes->count()} anime için hook üretiliyor...");
|
||||
$bar = $this->output->createProgressBar($animes->count());
|
||||
$bar->start();
|
||||
|
||||
$done = 0; $failed = 0;
|
||||
foreach ($animes as $anime) {
|
||||
$hook = $ai->generateDiscoveryHook($anime);
|
||||
if ($hook) {
|
||||
$anime->updateQuietly(['discovery_hook' => $hook]);
|
||||
$done++;
|
||||
} else {
|
||||
$failed++;
|
||||
}
|
||||
$bar->advance();
|
||||
usleep(300_000); // Rate limit — 0.3sn ara
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->newLine();
|
||||
$this->info("Tamamlandı: {$done} başarılı, {$failed} başarısız.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user