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

84 lines
1.4 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
*/
protected $signature = 'collect';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Collect info about new games';
/**
* List of parsers to run.
*
* @var array
*/
protected $parsers = [
2019-09-13 08:56:52 +03:00
//'Urq',
2019-09-12 20:03:56 +03:00
'Anivisual',
2019-09-13 08:56:52 +03:00
/*
2019-09-12 20:03:56 +03:00
'Kvester',
//'vndb',
'Apero',
'Instory',
// 'instead',
'Hyperbook',
'HyperbookEn',
'Questbook',
'Textadventures',
'IFDB',
'Dashingdon',
'Itch',
'Gamejolt',
2019-09-13 08:56:52 +03:00
'Steam',
*/
2019-09-12 20:03:56 +03:00
];
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach ($this->parsers as $parser) {
$cname = 'App\\Sources\\'.$parser;
try {
2019-09-13 08:56:52 +03:00
$parser = new $cname();
$games = $parser->parse();
foreach ($games as $game) {
$parser->saveGame($game);
}
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();
}
}