Instory RSS
This commit is contained in:
parent
8afce92f3c
commit
cf0345c9e4
59
Source/Instory.php
Normal file
59
Source/Instory.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?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 Source;
|
||||
|
||||
use \Game;
|
||||
|
||||
class Instory extends Source {
|
||||
public $title = "Instory";
|
||||
protected function parse() {
|
||||
$this->parseFeed('http://instory.top/feed/');
|
||||
}
|
||||
protected function parseFeed($feedUrl) {
|
||||
$string = $this->get_text($feedUrl);
|
||||
$string = mb_convert_encoding($string, 'UTF-8', 'auto');
|
||||
$service = new \Sabre\Xml\Service();
|
||||
$service->elementMap = [
|
||||
'{}item' => function(\Sabre\Xml\Reader $reader) {
|
||||
return \Sabre\Xml\Deserializer\keyValue($reader, '');
|
||||
},
|
||||
'{}channel' => function(\Sabre\Xml\Reader $reader) {
|
||||
return \Sabre\Xml\Deserializer\repeatingElements($reader, '{}item');
|
||||
},
|
||||
];
|
||||
try {
|
||||
$games = $service->parse($string)[0]['value'];
|
||||
} catch (\Sabre\Xml\LibXMLException $e) {
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
return "";
|
||||
}
|
||||
unset($string);
|
||||
foreach ($games as $gameBlock) {
|
||||
$date = strtotime($gameBlock['pubDate']);
|
||||
if ($date < $this->period) continue;
|
||||
$game = new Game;
|
||||
$game->title = trim($gameBlock['title']);
|
||||
$game->url = trim($gameBlock['link']);
|
||||
$game->description = trim($gameBlock['description']);
|
||||
$game->author = trim($gameBlock['dc:creator']);
|
||||
$this->output .= $game->print();
|
||||
}
|
||||
}
|
||||
}
|
2
run.php
2
run.php
|
@ -45,6 +45,7 @@ if ($parsers === 'all' || in_array('all', $parsers)) {
|
|||
'kvester',
|
||||
//'vndb',
|
||||
'apero',
|
||||
'instory',
|
||||
'instead',
|
||||
'hyperbook_ru',
|
||||
'hyperbook_en',
|
||||
|
@ -73,6 +74,7 @@ check ('Apero', 'apero');
|
|||
check ('Instead', 'instead');
|
||||
check ('Hyperbook', 'hyperbook_ru');
|
||||
check ('Questbook', 'questbook');
|
||||
check ('Instory', 'instory');
|
||||
check ('Anivisual', 'anivisual');
|
||||
// ------- English online libraries
|
||||
check ('HyperbookEn', 'hyperbook_en');
|
||||
|
|
Reference in a new issue