12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /*
- Microblog bot for game release notifications
- Copyright (C) 2017 Alexander Yakovlev
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- namespace Source;
- use \Game;
- class Qsp extends Source {
- public $title = "Библиотека QSP";
- protected function parse() {
- $text = $this->get_text("http://qsp.su/index.php?option=com_sobi2&sobi2Task=rss&no_html=1&catid=1&Itemid=55");
- $this->dom->loadStr($text, []);
- unset($text);
- $games = $this->dom->find('channel item');
- foreach ($games as $gameBlock) {
- $date = trim($gameBlock->find('pubDate')->innerHtml, "() \t\n\r\0\x0B");
- $date = new \DateTime($date);
- if ($date === false) continue;
- $date = $date->format('U');
- if ($date < $this->period) continue;
- $game = new Game;
- $game->author = trim($gameBlock->find('category')->innerHtml);
- $game->title = trim($gameBlock->find('title')->innerHtml);
- $game->url = trim($gameBlock->find('link')[0]->innerHtml);// not working because XML
- $game->description = trim($gameBlock->find('description')->innerHtml);
- $this->games[] = $game;
- }
- }
- }
|