42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
namespace Source;
|
|
|
|
use \Game;
|
|
|
|
class IFDB extends Source {
|
|
public $title = "IFDB";
|
|
protected function parse() {
|
|
$service = new \Sabre\Xml\Service();
|
|
$xml = $this->get_text("http://ifdb.tads.org/allnew-rss");
|
|
$service->elementMap = [
|
|
'{}item' => function(\Sabre\Xml\Reader $reader) {
|
|
$game = new Game;
|
|
$keyValue = \Sabre\Xml\Deserializer\keyValue($reader, '{}item');
|
|
if (isset($keyValue['{}title'])) {
|
|
$title = $keyValue['{}title'];
|
|
if (strpos($title, 'A new listing') === FALSE)
|
|
return [];
|
|
$title = str_replace('A new listing for ', '', $title);
|
|
$title = explode(' by ', $title);
|
|
$game->title = $title[0];
|
|
$game->author = $title[1];
|
|
}
|
|
if (isset($keyValue['{}link'])) {
|
|
$game->url = $keyValue['{}link'];
|
|
}
|
|
if (isset($keyValue['{}description'])) {
|
|
$game->description = $keyValue['{}description'];
|
|
}
|
|
if (isset($keyValue['{}pubDate'])) {
|
|
$game->date = strtotime($keyValue['{}pubDate']);
|
|
}
|
|
if ($game->date >= $this->period) {
|
|
$this->output .= $game->print();
|
|
}
|
|
return $game;
|
|
},
|
|
];
|
|
$dom = $service->parse($xml);
|
|
}
|
|
}
|