Itch parser improvements
This commit is contained in:
parent
54645025e7
commit
9cb6f721eb
|
@ -3,4 +3,4 @@ Originally a parser for Russian Interactive Fiction, now it supports English gam
|
|||
|
||||
Its function is simple: it scans some game hosting sites, finds the new games (published in the last week) and prints a neat list in Markdown format. All automatic.
|
||||
|
||||
The `parser.php` is Russian sites, `english.php` is English sites.
|
||||
The `russian.php` is Russian sites, `english.php` is English sites.
|
||||
|
|
|
@ -12,6 +12,12 @@ class Itch extends Source {
|
|||
'{}item' => function(\Sabre\Xml\Reader $reader) {
|
||||
$game = new Game;
|
||||
$keyValue = \Sabre\Xml\Deserializer\keyValue($reader, '{}item');
|
||||
if (isset($keyValue['{}pubDate'])) {
|
||||
$game->date = strtotime($keyValue['{}pubDate']);
|
||||
if ($game->date < $this->period) {
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
if (isset($keyValue['{}plainTitle'])) {
|
||||
$game->title = $keyValue['{}plainTitle'];
|
||||
}
|
||||
|
@ -19,14 +25,18 @@ class Itch extends Source {
|
|||
$game->url = $keyValue['{}link'];
|
||||
}
|
||||
if (isset($keyValue['{}description'])) {
|
||||
$game->description = $keyValue['{}description'];
|
||||
$game->description = trim(strip_tags($keyValue['{}description'], '<p><a><br>'));
|
||||
}
|
||||
if (isset($keyValue['{}pubDate'])) {
|
||||
$game->date = strtotime($keyValue['{}pubDate']);
|
||||
}
|
||||
if ($game->date >= $this->period) {
|
||||
$this->output .= $game->print();
|
||||
$game_page = $this->get_text($game->url);
|
||||
$this->dom->loadFromUrl($game->url);
|
||||
$lines = $this->dom->find('.game_info_panel_widget tr');
|
||||
foreach ($lines as $line) {
|
||||
$text = $line->find('td');
|
||||
if ($text->innerHtml == 'Author') {
|
||||
$game->author = strip_tags($text->nextSibling()->innerHtml);
|
||||
}
|
||||
}
|
||||
$this->output .= $game->print();
|
||||
return $game;
|
||||
},
|
||||
];
|
||||
|
|
Reference in a new issue