123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?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->games[] = $game;
- }
- return $game;
- },
- ];
- $dom = $service->parse($xml);
- }
- }
|