Archived
1
0
Fork 0

Itch parser improvements

This commit is contained in:
Alexander Yakovlev 2017-03-10 13:14:45 +07:00
parent 54645025e7
commit 9cb6f721eb
2 changed files with 17 additions and 7 deletions

View file

@ -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.

View file

@ -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;
},
];