83 lines
1.3 KiB
PHP
83 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use LaravelZero\Framework\Commands\Command;
|
|
use Log;
|
|
|
|
class Collect extends Command
|
|
{
|
|
/**
|
|
* The signature of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'collect {keyword?}';
|
|
|
|
/**
|
|
* The description of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Collect info about new games';
|
|
|
|
/**
|
|
* List of parsers to run.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $parsers = [
|
|
//'Anivisual',
|
|
//'Hyperbook',
|
|
//'HyperbookEn',
|
|
//'Apero',
|
|
'Questbook',
|
|
/*
|
|
'Textadventures',
|
|
'IFDB',
|
|
'Itch',
|
|
'Steam',
|
|
'Urq',
|
|
'Kvester',
|
|
'vndb',
|
|
'Instory',
|
|
'instead',
|
|
'Dashingdon',
|
|
'Gamejolt',
|
|
*/
|
|
];
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
Log::debug('Collecting.');
|
|
foreach ($this->parsers as $parser) {
|
|
$cname = 'App\\Sources\\'.$parser;
|
|
Log::debug($parser);
|
|
try {
|
|
$parser = new $cname();
|
|
$parser->parse();
|
|
} catch (\Exception $e) {
|
|
Log::error($e->getMessage());
|
|
Log::debug($e->getTraceAsString());
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Define the command's schedule.
|
|
*
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
* @return void
|
|
*/
|
|
public function schedule(Schedule $schedule): void
|
|
{
|
|
$schedule->command(static::class)->daily();
|
|
}
|
|
}
|