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

83 lines
1.3 KiB
PHP
Raw Normal View History

2019-09-12 20:03:56 +03:00
<?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
*/
2020-01-04 19:46:58 +02:00
protected $signature = 'collect {keyword?}';
2019-09-12 20:03:56 +03:00
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Collect info about new games';
/**
* List of parsers to run.
*
* @var array
*/
protected $parsers = [
2020-01-04 19:46:58 +02:00
//'Anivisual',
'Hyperbook',
2020-01-05 10:10:04 +02:00
'HyperbookEn',
2019-11-30 08:08:17 +02:00
/*
2019-09-12 20:03:56 +03:00
'Apero',
'Questbook',
'Textadventures',
'IFDB',
'Itch',
2019-09-13 08:56:52 +03:00
'Steam',
2019-11-29 18:42:16 +02:00
'Urq',
'Kvester',
'vndb',
'Instory',
'instead',
'Dashingdon',
'Gamejolt',
2019-09-13 08:56:52 +03:00
*/
2019-09-12 20:03:56 +03:00
];
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
2020-01-04 19:46:58 +02:00
Log::debug('Collecting.');
2019-09-12 20:03:56 +03:00
foreach ($this->parsers as $parser) {
$cname = 'App\\Sources\\'.$parser;
2019-11-29 18:42:16 +02:00
Log::debug($parser);
2019-09-12 20:03:56 +03:00
try {
2019-09-13 08:56:52 +03:00
$parser = new $cname();
2019-11-30 08:08:17 +02:00
$parser->parse();
2019-09-12 20:03:56 +03:00
} 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();
}
}