41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
namespace Source;
|
|
|
|
use \Game;
|
|
|
|
class Storymaze extends Source {
|
|
public $title = "Storymaze";
|
|
protected function parse() {
|
|
$api = $this->get_text('http://storymaze.ru/api/stories/search?count=10&offset=0&asc=');
|
|
$api = json_decode($api, TRUE);
|
|
if (empty($api)) {
|
|
return;
|
|
}
|
|
foreach ($api as $gameData) {
|
|
$date = strtotime($gameData['publishStart']);
|
|
if ($date < $this->period) continue;
|
|
$game = new Game;
|
|
$game->title = $gameData['name'];
|
|
$game->url = "http://storymaze.ru/story/view/".$gameData['id'].".html";
|
|
$game->description = $gameData['description'];
|
|
if (strpos($gameData['description'], '...</a>') !== FALSE) { // описание укорочено
|
|
$text = $this->get_text($game->url);
|
|
$this->dom->loadStr($text, []);
|
|
unset($text);
|
|
$storytext = $this->dom->find('.story-text p');
|
|
$description = "";
|
|
$length = count($storytext);
|
|
foreach ($storytext as $text) {
|
|
if($text->getAttribute('class') === 'story-name') {
|
|
continue;
|
|
}
|
|
$description .= trim($text->innerHtml);
|
|
}
|
|
$game->description = $description;
|
|
}
|
|
$game->author = $gameData['authorName'];
|
|
$this->output .= $game->print();
|
|
}
|
|
}
|
|
}
|