Upgrade Laravel Zero
This commit is contained in:
parent
997dd373f5
commit
3f86805603
|
@ -28,23 +28,23 @@ class Collect extends Command
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $parsers = [
|
protected $parsers = [
|
||||||
//'Urq',
|
|
||||||
'Anivisual',
|
'Anivisual',
|
||||||
/*
|
|
||||||
'Kvester',
|
|
||||||
//'vndb',
|
|
||||||
'Apero',
|
'Apero',
|
||||||
'Instory',
|
|
||||||
// 'instead',
|
|
||||||
'Hyperbook',
|
'Hyperbook',
|
||||||
'HyperbookEn',
|
|
||||||
'Questbook',
|
'Questbook',
|
||||||
'Textadventures',
|
'Textadventures',
|
||||||
'IFDB',
|
'IFDB',
|
||||||
'Dashingdon',
|
|
||||||
'Itch',
|
'Itch',
|
||||||
'Gamejolt',
|
|
||||||
'Steam',
|
'Steam',
|
||||||
|
/*
|
||||||
|
'Urq',
|
||||||
|
'Kvester',
|
||||||
|
'vndb',
|
||||||
|
'Instory',
|
||||||
|
'instead',
|
||||||
|
'HyperbookEn',
|
||||||
|
'Dashingdon',
|
||||||
|
'Gamejolt',
|
||||||
*/
|
*/
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -55,8 +55,10 @@ class Collect extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
Log::debug('Collecting.');
|
||||||
foreach ($this->parsers as $parser) {
|
foreach ($this->parsers as $parser) {
|
||||||
$cname = 'App\\Sources\\'.$parser;
|
$cname = 'App\\Sources\\'.$parser;
|
||||||
|
Log::debug($parser);
|
||||||
try {
|
try {
|
||||||
$parser = new $cname();
|
$parser = new $cname();
|
||||||
$games = $parser->parse();
|
$games = $parser->parse();
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace App;
|
||||||
use \Symfony\Component\DomCrawler\Crawler;
|
use \Symfony\Component\DomCrawler\Crawler;
|
||||||
use \GuzzleHttp\Client as GuzzleClient;
|
use \GuzzleHttp\Client as GuzzleClient;
|
||||||
use App\Models\Game;
|
use App\Models\Game;
|
||||||
|
use Log;
|
||||||
|
|
||||||
abstract class Source {
|
abstract class Source {
|
||||||
// Title
|
// Title
|
||||||
|
@ -91,7 +92,8 @@ abstract class Source {
|
||||||
* Save the game if not a duplicate.
|
* Save the game if not a duplicate.
|
||||||
*/
|
*/
|
||||||
public function saveGame(Game $game) {
|
public function saveGame(Game $game) {
|
||||||
$game->source = self::class;
|
Log::debug('Saving game '.$game->title);
|
||||||
|
$game->source = get_class($this);
|
||||||
$dbmodel = NULL;
|
$dbmodel = NULL;
|
||||||
if (isset($game->source_id)) {
|
if (isset($game->source_id)) {
|
||||||
$dbmodel = Game::where('source', $game->source)
|
$dbmodel = Game::where('source', $game->source)
|
||||||
|
@ -110,9 +112,13 @@ abstract class Source {
|
||||||
* Get the date of the last scraped game for this source.
|
* Get the date of the last scraped game for this source.
|
||||||
*/
|
*/
|
||||||
protected function getLastDate() {
|
protected function getLastDate() {
|
||||||
Game::where('source', self::class)
|
$date = Game::where('source', self::class)
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->limit(1)
|
->limit(1)
|
||||||
->value('created_at');
|
->value('created_at');
|
||||||
|
if (!$date) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return (new \DateTime($date));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Anivisual extends Source {
|
||||||
'Ноября' => 'November',
|
'Ноября' => 'November',
|
||||||
'Декабря' => 'December',
|
'Декабря' => 'December',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function parse() {
|
public function parse() {
|
||||||
$text = $this->get_text('http://anivisual.net/stuff/1');
|
$text = $this->get_text('http://anivisual.net/stuff/1');
|
||||||
$this->loadStr($text);
|
$this->loadStr($text);
|
||||||
|
@ -49,7 +50,7 @@ class Anivisual extends Source {
|
||||||
$date = str_replace($ruM, $enM, $date);
|
$date = str_replace($ruM, $enM, $date);
|
||||||
}
|
}
|
||||||
$date = \DateTime::createFromFormat('d F Y', $date);
|
$date = \DateTime::createFromFormat('d F Y', $date);
|
||||||
if ($date >= $lastDate) {
|
if (!empty($lastDate) && $date >= $lastDate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$game->date = $date;
|
$game->date = $date;
|
||||||
|
|
|
@ -26,7 +26,8 @@ use \App\Source;
|
||||||
* Проблема парсера в том, что на Аперо часто поломана кодировка UTF-8.
|
* Проблема парсера в том, что на Аперо часто поломана кодировка UTF-8.
|
||||||
*/
|
*/
|
||||||
class Apero extends Source {
|
class Apero extends Source {
|
||||||
public $title = "Apero";
|
public $title = "Apero";
|
||||||
|
|
||||||
public function parse() {
|
public function parse() {
|
||||||
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
|
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
|
||||||
'order_by' => 'by_public',
|
'order_by' => 'by_public',
|
||||||
|
@ -40,7 +41,8 @@ class Apero extends Source {
|
||||||
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
||||||
$this->loadStr($text);
|
$this->loadStr($text);
|
||||||
$this->parseIndex();
|
$this->parseIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseIndex()
|
public function parseIndex()
|
||||||
{
|
{
|
||||||
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
|
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
|
||||||
|
|
114
composer.json
114
composer.json
|
@ -1,59 +1,59 @@
|
||||||
{
|
{
|
||||||
"name": "laravel-zero/laravel-zero",
|
"name": "laravel-zero/laravel-zero",
|
||||||
"description": "The Laravel Zero Framework.",
|
"description": "The Laravel Zero Framework.",
|
||||||
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
|
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
|
||||||
"homepage": "https://laravel-zero.com",
|
"homepage": "https://laravel-zero.com",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
|
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
|
||||||
"source": "https://github.com/laravel-zero/laravel-zero"
|
"source": "https://github.com/laravel-zero/laravel-zero"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Nuno Maduro",
|
"name": "Nuno Maduro",
|
||||||
"email": "enunomaduro@gmail.com"
|
"email": "enunomaduro@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"sabre/xml": "^2.0",
|
"sabre/xml": "^2.0",
|
||||||
"addwiki/mediawiki-api": "^0.7.2",
|
"addwiki/mediawiki-api": "^0.7.2",
|
||||||
"symfony/dom-crawler": "^4.0",
|
"symfony/dom-crawler": "^4.0",
|
||||||
"symfony/css-selector": "^4.0",
|
"symfony/css-selector": "^4.0",
|
||||||
"longman/telegram-bot": "dev-master",
|
"longman/telegram-bot": "dev-master",
|
||||||
"revolution/laravel-mastodon-api": "dev-master",
|
"revolution/laravel-mastodon-api": "dev-master",
|
||||||
"cocur/slugify": "^3.2",
|
"cocur/slugify": "^3.2",
|
||||||
"illuminate/database": "5.8.*",
|
"illuminate/database": "^6.0.0",
|
||||||
"laravel-zero/framework": "5.8.*",
|
"laravel-zero/framework": "^6.0.0",
|
||||||
"ryakad/pandoc-php": "^1.0"
|
"ryakad/pandoc-php": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mockery/mockery": "^1.0",
|
"mockery/mockery": "^1.0",
|
||||||
"nunomaduro/larastan": "^0.4.0",
|
"nunomaduro/larastan": "^0.4.0",
|
||||||
"phpunit/phpunit": "^7.5"
|
"phpunit/phpunit": "^7.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "app/"
|
"App\\": "app/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\": "tests/"
|
"Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"optimize-autoloader": true
|
"optimize-autoloader": true
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
"@php application app:rename"
|
"@php application app:rename"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"bin": ["ifnews"]
|
"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