Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/Source/Instead.php

34 lines
1.2 KiB
PHP
Raw Normal View History

2017-01-23 09:00:42 +02:00
<?php
2017-01-23 09:15:26 +02:00
namespace Source;
use \Game;
2017-01-23 09:00:42 +02:00
class Instead extends Source {
public $title = "INSTEAD репозиторий";
2017-01-23 09:00:42 +02:00
protected function insteadfeed($url) {
2017-07-13 18:07:14 +03:00
$text = $this->get_text($url);
2018-03-24 21:42:13 +02:00
$this->loadStr($text);
2017-07-13 18:07:14 +03:00
unset($text);
2018-03-24 21:42:13 +02:00
$this->dom->filter('.game')->each(function($gameBlock) {
$date = trim($gameBlock->filter('.b .date b')->text());
2017-01-23 09:15:26 +02:00
$date = \DateTime::createFromFormat('Y.m.d', $date);
2017-01-23 09:00:42 +02:00
$date = $date->format('U');
2018-03-24 21:42:13 +02:00
if ($date < $this->period) return;
2017-01-23 09:00:42 +02:00
$game = new Game;
2018-03-24 21:42:13 +02:00
$game->author = str_replace(trim($gameBlock->filter('span.author')->first()->text()), 'Автор: ', '');
$game->title = trim($gameBlock->filter('h2:first-child a:first-child')->first()->text());
$game->url = 'http://instead-games.ru/'.trim($gameBlock->filter('h2:first-child a:first-child')->first()->attr('href'));
2017-01-23 09:00:42 +02:00
$this->output .= $game->print();
2018-03-24 21:42:13 +02:00
});
2017-01-23 09:00:42 +02:00
}
protected function parse() {
$this->insteadfeed("http://instead-games.ru/");
if (FORMAT === 'HTML') {
$this->output .= "<h5>Песочница</h5>\n";
} elseif (FORMAT === 'MARKDOWN') {
$this->output .= "##### Песочница\n";
}
2017-01-23 09:00:42 +02:00
$this->insteadfeed("http://instead-games.ru/index.php?approved=0");
}
}