parent
e903eb25fc
commit
4b03920b29
|
@ -38,7 +38,6 @@ class Collect extends Command
|
||||||
'Itch',
|
'Itch',
|
||||||
'Instead',
|
'Instead',
|
||||||
'Steam',
|
'Steam',
|
||||||
'Kvester',
|
|
||||||
'Urq',
|
'Urq',
|
||||||
'Instory',
|
'Instory',
|
||||||
'Ifiction',
|
'Ifiction',
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
A set of utilities for tracking text-based game releases
|
|
||||||
Copyright (C) 2017-2018 Alexander Yakovlev
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
namespace App\Sources;
|
|
||||||
|
|
||||||
use \App\Models\Game;
|
|
||||||
use \App\Source;
|
|
||||||
use \App\Models\Language;
|
|
||||||
use \App\Models\Author;
|
|
||||||
|
|
||||||
class Kvester extends Source {
|
|
||||||
public $title = "Квестер";
|
|
||||||
public $keyword = 'kvester';
|
|
||||||
protected $baseUrl = 'http://kvester.ru';
|
|
||||||
public function parse() {
|
|
||||||
$text = $this->get_text($this->baseUrl."/catalog?sort=date");
|
|
||||||
if (empty($text)) {
|
|
||||||
// Квестер опять упал
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->loadStr($text);
|
|
||||||
unset($text);
|
|
||||||
$this->dom->filter('.catalog-item')->each(function($gameBlock){
|
|
||||||
$date = trim($gameBlock->filter('.cell-2 .date')->text(), "() \t\n\r\0\x0B");
|
|
||||||
$date = \DateTime::createFromFormat("d.m.y", $date);
|
|
||||||
if ($date === false) return;
|
|
||||||
$game = new Game;
|
|
||||||
$game->release_date = $date;
|
|
||||||
$author = trim(strip_tags($gameBlock->filter('.cell-2 .author')->text()));
|
|
||||||
$game->title = trim($gameBlock->filter('.cell-2 h3 a')->text());
|
|
||||||
$game->url = $this->baseUrl.trim($gameBlock->filter('.cell-2 h3 a')->attr('href'));
|
|
||||||
$game->description = "";
|
|
||||||
|
|
||||||
$this->loadStr($this->get_text($game->url));
|
|
||||||
$game->description = $this->dom->filter('.description')->first()->text();
|
|
||||||
$game = $this->findGame($game);
|
|
||||||
$game->save();
|
|
||||||
|
|
||||||
$language = Language::findByCode('ru');
|
|
||||||
$game->languages()->sync([$language->id]);
|
|
||||||
|
|
||||||
if (!empty($author)) {
|
|
||||||
$author_model = Author::findByName($author);
|
|
||||||
if (empty($author_model)) {
|
|
||||||
$author_model = new Author();
|
|
||||||
$author_model->name = $author;
|
|
||||||
$author_model->save();
|
|
||||||
}
|
|
||||||
$game->authors()->sync([$author_model->id]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public function checkPage($url) {
|
|
||||||
return (strpos($url, $this->baseUrl.'/game/') !== FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue