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;
|
||||
|
|
|
@ -26,7 +26,8 @@ use \App\Source;
|
|||
* Проблема парсера в том, что на Аперо часто поломана кодировка UTF-8.
|
||||
*/
|
||||
class Apero extends Source {
|
||||
public $title = "Apero";
|
||||
public $title = "Apero";
|
||||
|
||||
public function parse() {
|
||||
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
|
||||
'order_by' => 'by_public',
|
||||
|
@ -40,7 +41,8 @@ class Apero extends Source {
|
|||
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
||||
$this->loadStr($text);
|
||||
$this->parseIndex();
|
||||
}
|
||||
}
|
||||
|
||||
public function parseIndex()
|
||||
{
|
||||
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
|
||||
|
|
114
composer.json
114
composer.json
|
@ -1,59 +1,59 @@
|
|||
{
|
||||
"name": "laravel-zero/laravel-zero",
|
||||
"description": "The Laravel Zero Framework.",
|
||||
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
|
||||
"homepage": "https://laravel-zero.com",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
|
||||
"source": "https://github.com/laravel-zero/laravel-zero"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "enunomaduro@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"sabre/xml": "^2.0",
|
||||
"addwiki/mediawiki-api": "^0.7.2",
|
||||
"symfony/dom-crawler": "^4.0",
|
||||
"symfony/css-selector": "^4.0",
|
||||
"longman/telegram-bot": "dev-master",
|
||||
"revolution/laravel-mastodon-api": "dev-master",
|
||||
"cocur/slugify": "^3.2",
|
||||
"illuminate/database": "5.8.*",
|
||||
"laravel-zero/framework": "5.8.*",
|
||||
"ryakad/pandoc-php": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/larastan": "^0.4.0",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"scripts": {
|
||||
"post-create-project-cmd": [
|
||||
"@php application app:rename"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"bin": ["ifnews"]
|
||||
"name": "laravel-zero/laravel-zero",
|
||||
"description": "The Laravel Zero Framework.",
|
||||
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
|
||||
"homepage": "https://laravel-zero.com",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
|
||||
"source": "https://github.com/laravel-zero/laravel-zero"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "enunomaduro@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"sabre/xml": "^2.0",
|
||||
"addwiki/mediawiki-api": "^0.7.2",
|
||||
"symfony/dom-crawler": "^4.0",
|
||||
"symfony/css-selector": "^4.0",
|
||||
"longman/telegram-bot": "dev-master",
|
||||
"revolution/laravel-mastodon-api": "dev-master",
|
||||
"cocur/slugify": "^3.2",
|
||||
"illuminate/database": "^6.0.0",
|
||||
"laravel-zero/framework": "^6.0.0",
|
||||
"ryakad/pandoc-php": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/larastan": "^0.4.0",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"scripts": {
|
||||
"post-create-project-cmd": [
|
||||
"@php application app:rename"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"bin": ["ifnews"]
|
||||
}
|
||||
|
|
1675
composer.lock
generated
1675
composer.lock
generated
File diff suppressed because it is too large
Load diff
Reference in a new issue