Upgrade Laravel Zero
This commit is contained in:
parent
997dd373f5
commit
3f86805603
|
@ -28,23 +28,23 @@ class Collect extends Command
|
|||
* @var array
|
||||
*/
|
||||
protected $parsers = [
|
||||
//'Urq',
|
||||
'Anivisual',
|
||||
/*
|
||||
'Kvester',
|
||||
//'vndb',
|
||||
'Apero',
|
||||
'Instory',
|
||||
// 'instead',
|
||||
'Hyperbook',
|
||||
'HyperbookEn',
|
||||
'Questbook',
|
||||
'Textadventures',
|
||||
'IFDB',
|
||||
'Dashingdon',
|
||||
'Itch',
|
||||
'Gamejolt',
|
||||
'Steam',
|
||||
/*
|
||||
'Urq',
|
||||
'Kvester',
|
||||
'vndb',
|
||||
'Instory',
|
||||
'instead',
|
||||
'HyperbookEn',
|
||||
'Dashingdon',
|
||||
'Gamejolt',
|
||||
*/
|
||||
];
|
||||
|
||||
|
@ -55,8 +55,10 @@ class Collect extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::debug('Collecting.');
|
||||
foreach ($this->parsers as $parser) {
|
||||
$cname = 'App\\Sources\\'.$parser;
|
||||
Log::debug($parser);
|
||||
try {
|
||||
$parser = new $cname();
|
||||
$games = $parser->parse();
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace App;
|
|||
use \Symfony\Component\DomCrawler\Crawler;
|
||||
use \GuzzleHttp\Client as GuzzleClient;
|
||||
use App\Models\Game;
|
||||
use Log;
|
||||
|
||||
abstract class Source {
|
||||
// Title
|
||||
|
@ -91,7 +92,8 @@ abstract class Source {
|
|||
* Save the game if not a duplicate.
|
||||
*/
|
||||
public function saveGame(Game $game) {
|
||||
$game->source = self::class;
|
||||
Log::debug('Saving game '.$game->title);
|
||||
$game->source = get_class($this);
|
||||
$dbmodel = NULL;
|
||||
if (isset($game->source_id)) {
|
||||
$dbmodel = Game::where('source', $game->source)
|
||||
|
@ -110,9 +112,13 @@ abstract class Source {
|
|||
* Get the date of the last scraped game for this source.
|
||||
*/
|
||||
protected function getLastDate() {
|
||||
Game::where('source', self::class)
|
||||
$date = Game::where('source', self::class)
|
||||
->orderBy('created_at', 'desc')
|
||||
->limit(1)
|
||||
->value('created_at');
|
||||
if (!$date) {
|
||||
return NULL;
|
||||
}
|
||||
return (new \DateTime($date));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class Anivisual extends Source {
|
|||
'Ноября' => 'November',
|
||||
'Декабря' => 'December',
|
||||
];
|
||||
|
||||
public function parse() {
|
||||
$text = $this->get_text('http://anivisual.net/stuff/1');
|
||||
$this->loadStr($text);
|
||||
|
@ -49,7 +50,7 @@ class Anivisual extends Source {
|
|||
$date = str_replace($ruM, $enM, $date);
|
||||
}
|
||||
$date = \DateTime::createFromFormat('d F Y', $date);
|
||||
if ($date >= $lastDate) {
|
||||
if (!empty($lastDate) && $date >= $lastDate) {
|
||||
return;
|
||||
}
|
||||
$game->date = $date;
|
||||
|
|
|
@ -27,6 +27,7 @@ use \App\Source;
|
|||
*/
|
||||
class Apero extends Source {
|
||||
public $title = "Apero";
|
||||
|
||||
public function parse() {
|
||||
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
|
||||
'order_by' => 'by_public',
|
||||
|
@ -41,6 +42,7 @@ class Apero extends Source {
|
|||
$this->loadStr($text);
|
||||
$this->parseIndex();
|
||||
}
|
||||
|
||||
public function parseIndex()
|
||||
{
|
||||
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
"longman/telegram-bot": "dev-master",
|
||||
"revolution/laravel-mastodon-api": "dev-master",
|
||||
"cocur/slugify": "^3.2",
|
||||
"illuminate/database": "5.8.*",
|
||||
"laravel-zero/framework": "5.8.*",
|
||||
"illuminate/database": "^6.0.0",
|
||||
"laravel-zero/framework": "^6.0.0",
|
||||
"ryakad/pandoc-php": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
1675
composer.lock
generated
1675
composer.lock
generated
File diff suppressed because it is too large
Load diff
Reference in a new issue