Archived
1
0
Fork 0
This repository has been archived on 2021-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
ifnews/app/Commands/Collect.php
2020-01-05 16:19:04 +07:00

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();
}
}