Archived
1
0
Fork 0

Фильтр уникальности для Itch

This commit is contained in:
Alexander Yakovlev 2018-04-06 10:45:58 +07:00
parent 361ff14b2a
commit aa2bab8399

View file

@ -6,6 +6,7 @@ use \Pandoc\Pandoc;
class Itch extends Source { class Itch extends Source {
public $title = "Itch.io"; public $title = "Itch.io";
public $games = [];
protected function parse_tag($url) { protected function parse_tag($url) {
$service = new \Sabre\Xml\Service(); $service = new \Sabre\Xml\Service();
$xml = $this->get_text($url); $xml = $this->get_text($url);
@ -36,7 +37,7 @@ class Itch extends Source {
$game->author = strip_tags($text->nextAll()->first()->html()); $game->author = strip_tags($text->nextAll()->first()->html());
} }
}); });
$this->output .= $game->print(); $this->games[] = $game->print();
return $game; return $game;
}, },
]; ];
@ -46,7 +47,12 @@ class Itch extends Source {
} }
protected function parse() { protected function parse() {
$this->parse_tag("https://itch.io/games/newest/tag-text-based.xml"); $this->parse_tag("https://itch.io/games/newest/tag-text-based.xml");
$this->parse_tag("https://itch.io/games/newest/tag-twine.xml");
$this->parse_tag("https://itch.io/games/newest/tag-interactive-fiction.xml"); $this->parse_tag("https://itch.io/games/newest/tag-interactive-fiction.xml");
$this->games = array_unique($this->games);
foreach ($this->games as $game) {
$this->output .= $game;
}
} }
public function checkPage($url) { public function checkPage($url) {
return (strpos($url,'.itch.io/') !== FALSE); return (strpos($url,'.itch.io/') !== FALSE);