ifhub
/
ifnews
Archived
1
0
Fork 0

game sources

This commit is contained in:
Alexander Yakovlev 2019-09-13 02:30:03 +07:00
parent f73d5bb412
commit d6afa0e6fa
Signed by: oreolek
GPG Key ID: 1CDC4B7820C93BD3
19 changed files with 68 additions and 41 deletions

View File

@ -40,7 +40,7 @@ abstract class Source {
$this->dom = new Crawler($html);
}
abstract protected function parse();
abstract public function parse();
/**
* System function to download page HTML.

View File

@ -37,7 +37,7 @@ class Anivisual extends Source {
'Ноября' => 'November',
'Декабря' => 'December',
];
protected function parse() {
public function parse() {
$text = $this->get_text('http://anivisual.net/stuff/1');
$this->loadStr($text);
unset($text);

View File

@ -27,7 +27,7 @@ use \App\Source;
*/
class Apero extends Source {
public $title = "Apero";
protected function parse() {
public function parse() {
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
'order_by' => 'by_public',
]);
@ -41,7 +41,7 @@ class Apero extends Source {
$this->loadStr($text);
$this->parseIndex();
}
protected function parseIndex()
public function parseIndex()
{
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );

View File

@ -25,7 +25,7 @@ class Axma extends Source {
public $title = "Библиотека AXMA (самая новая)";
protected $games = array();
protected $rootUrl = 'https://axma.info/library/';
protected function parse() {
public function parse() {
$i = 0;
$text = $this->get_text('https://axma.info/library/?sort=last&from='.$i);
$this->loadStr($text);

View File

@ -26,7 +26,7 @@ use \App\Source;
*/
class Dashingdon extends Source {
public $title = "DashingDon";
protected function parse() {
public function parse() {
$text = $this->get_text("https://dashingdon.com/screenreader/");
$this->loadStr($text);
unset($text);

View File

@ -23,7 +23,7 @@ use \App\Source;
class Gamejolt extends Source {
public $title = "GameJolt";
protected function parse_tag($url) {
public function parse_tag($url) {
$data = json_decode($this->get_text($url));
if (empty($data) or !isset($data->payload)) {
echo 'GameJolt data empty';
@ -44,7 +44,7 @@ class Gamejolt extends Source {
}
}
}
protected function parse() {
public function parse() {
try {
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/twine");
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/renpy");

View File

@ -25,7 +25,7 @@ class Hyperbook extends Source {
public $title = "Гиперкнига";
protected $games = array();
protected $rootUrl = 'http://hyperbook.ru';
protected function parse() {
public function parse() {
$text = $this->get_text($this->rootUrl.'/lib.php?sort=time');
$this->loadStr($text);
unset($text);

View File

@ -23,7 +23,7 @@ use \App\Source;
class IFDB extends Source {
public $title = "IFDB";
protected function parse() {
public function parse() {
$service = new \Sabre\Xml\Service();
$xml = $this->get_text("http://ifdb.tads.org/allnew-rss");
$xml = tidy_repair_string($xml, [

View File

@ -37,13 +37,8 @@ class Instead extends Source {
$this->saveGame($game);
});
}
protected function parse() {
public function parse() {
$this->insteadfeed("http://instead-games.ru/");
if (FORMAT === 'HTML') {
$this->output .= "<h5>Песочница</h5>\n";
} elseif (FORMAT === 'MARKDOWN') {
$this->output .= "##### Песочница\n";
}
$this->insteadfeed("http://instead-games.ru/index.php?approved=0");
}
public function checkPage($url) {

View File

@ -23,10 +23,10 @@ use \App\Source;
class Instory extends Source {
public $title = "Instory";
protected function parse() {
public function parse() {
$this->parseFeed('http://instory.su/feed/');
}
protected function parseFeed($feedUrl) {
public function parseFeed($feedUrl) {
$string = $this->get_text($feedUrl);
$string = mb_convert_encoding($string, 'UTF-8', 'auto');
$service = new \Sabre\Xml\Service();
@ -47,14 +47,14 @@ class Instory extends Source {
}
unset($string);
foreach ($games as $gameBlock) {
$date = strtotime($gameBlock['pubDate']);
if ($date < $this->period) continue;
$date = strtotime($gameBlock['pubDate']);
// TODO abort if pubdate equals to last parsed game
$game = new Game;
$game->title = trim($gameBlock['title']);
$game->url = trim($gameBlock['link']);
$game->description = trim($gameBlock['description']);
$game->author = trim($gameBlock['{http://purl.org/dc/elements/1.1/}creator']);
$this->output .= $game->print();
$game->author = trim($gameBlock['{http://purl.org/dc/elements/1.1/}creator']);
$this->saveGame($game);
}
}
public function checkPage($url) {

View File

@ -27,7 +27,7 @@ class Itch extends Source {
public $queue = [];
public $games = [];
public $print_description = FALSE;
protected function parse_tag($url) {
public function parse_tag($url) {
$max_pages = 4; // load 30*4 = 120 latest games
for ($i = 1; $i <= $max_pages; $i++) {
$cururl = $url.'?format=json&page='.$i;
@ -47,12 +47,12 @@ class Itch extends Source {
}
}
}
protected function parse() {
public function parse() {
global $argv;
if (isset($argv[2])) {
$game_page = $this->get_text($argv[2]);
$this->loadStr($game_page, []);
$this->output .= $this->page($argv[2])->print();
$this->loadStr($game_page);
$this->saveGame($this->page($argv[2]));
} else {
$this->parse_tag("https://itch.io/games/newest/tag-text-based");
$this->parse_tag("https://itch.io/games/newest/tag-twine");
@ -60,11 +60,9 @@ class Itch extends Source {
$this->queue = array_unique($this->queue);
foreach ($this->queue as $game) {
$game_page = $this->get_text($game->url);
$this->loadStr($game_page, []);
$this->loadStr($game_page);
$game = $this->page($game->url);
if ($game->date < $this->period) {
continue;
}
// if ($game->date < $this->period) {
$this->games[] = $game->print();
}
$this->games = array_unique($this->games);

View File

@ -24,7 +24,7 @@ use \App\Source;
class Kvester extends Source {
public $title = "Квестер";
protected $baseUrl = 'http://kvester.ru';
protected function parse() {
public function parse() {
$text = $this->get_text($this->baseUrl."/catalog?sort=date");
$this->loadStr($text);
unset($text);

View File

@ -23,7 +23,7 @@ use \App\Source;
class Qsp extends Source {
public $title = "Библиотека QSP";
protected function parse() {
public function parse() {
$text = $this->get_text("http://qsp.su/index.php?option=com_sobi2&sobi2Task=rss&no_html=1&catid=1&Itemid=55");
$this->loadStr($text);
unset($text);

View File

@ -24,7 +24,7 @@ use \App\Source;
class Questbook extends Source {
public $title = "Сторигеймы";
protected function parse() {
public function parse() {
global $argv;
if (isset($argv[2])) {
$game_page = $this->get_text($argv[2]);
@ -36,7 +36,7 @@ class Questbook extends Source {
}
}
protected function parseFeed($feedUrl) {
public function parseFeed($feedUrl) {
$string = $this->get_text($feedUrl);
$string = mb_convert_encoding($string, 'UTF-8', 'auto');
$service = new \Sabre\Xml\Service();

View File

@ -42,7 +42,7 @@ class Steam extends Source {
'ноя.' => 'November',
'дек.' => 'December',
];
protected function parse_tag($tag) {
public function parse_tag($tag) {
$url = 'https://store.steampowered.com/search/';
$url .= '?'.http_build_query([
'sort_by' => 'Released_DESC',
@ -66,7 +66,7 @@ class Steam extends Source {
}
});
}
protected function parse() {
public function parse() {
global $argv;
if (isset($argv[2])) {
$game = $this->page($argv[2]);

View File

@ -24,7 +24,7 @@ use \Symfony\Component\DomCrawler\Crawler;
class Textadventures extends Source {
public $title = "Textadventures.co.uk";
protected function parse() {
public function parse() {
$text = $this->get_text('http://textadventures.co.uk/games/latest');
$this->loadStr($text);
unset($text);

View File

@ -23,7 +23,7 @@ use \App\Source;
class Urq extends Source {
public $title = "Библиотека URQ";
protected function parse() {
public function parse() {
$text = $this->get_text('http://urq.plut.info/node/209');
$this->loadStr($text);
unset($text);
@ -31,8 +31,8 @@ class Urq extends Source {
$game = new Game;
$game->author = trim($gameBlock->filter('.views-field-taxonomy-vocabulary-2')->first()->text());
$game->title = trim($gameBlock->filter('.views-field-title')->text());
$game->url = 'http://urq.plut.info'.trim($gameBlock->filter('.views-field-title a')->attr('href'));
$this->output .= $game->print();
$game->url = 'http://urq.plut.info'.trim($gameBlock->filter('.views-field-title a')->attr('href'));
$this->saveGame($game);
});
}
public function checkPage($url) {

View File

@ -23,7 +23,7 @@ use \App\Source;
class VNDB extends Source {
public $title = "VNDB";
protected function parse() {
public function parse() {
global $config;
$client = new Client();
$client->connect();

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Sources extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('games', function (Blueprint $table) {
$table->string('source')->nullable();
$table->string('source_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('games', function (Blueprint $table) {
$table->dropColumn('source');
$table->dropColumn('source_id');
});
}
}