Archived
1
0
Fork 0

Anivisual с деталями

This commit is contained in:
Alexander Yakovlev 2018-09-14 13:05:50 +07:00
parent bd2edde52c
commit a1b1cc5936

View file

@ -48,11 +48,13 @@ class Anivisual extends Source {
$date = \DateTime::createFromFormat('d F Y', $date);
$date = $date->format('U');
if ($date < $this->period) return;
$game = new Game;
$link = $gameBlock->filter('.novel-ttl a')->first();
$game->title = htmlspecialchars_decode($link->html());
$game->url = 'http://anivisual.net'.$link->attr('href');
$game->description = $gameBlock->filter('span')->first()->text();
$link = 'http://anivisual.net'.$link->attr('href');
$game = $this->page($link);
//$game = new Game;
//$game->title = htmlspecialchars_decode($link->html());
//$game->url = 'http://anivisual.net'.$link->attr('href');
//$game->description = $gameBlock->filter('span')->first()->text();
$games[] = $game;
@ -63,6 +65,9 @@ class Anivisual extends Source {
return (strpos($url,'http://anivisual.net/stuff/') !== FALSE);
}
public function page($url) {
$text = $this->get_text($url);
$this->loadStr($text);
unset($text);
$game = new Game;
$game->url = $url;
$gameBlock = $this->dom->filter('#casing-box');
@ -74,8 +79,25 @@ class Anivisual extends Source {
$game->date = \DateTime::createFromFormat('d F Y', $date);
unset($date);
}
$game->title = htmlspecialchars_decode($gameBlock->filter('h1.logo')->text());
$game->description = $this->dom->filter('#content > section > span')->text();
$title = $this->dom->filter('h1.logo')->first();
if ($title->count() > 0) {
$game->title = htmlspecialchars_decode($title->text());
}
$game->description = $gameBlock->filter('#content > section > span')->first()->text();
$game->description = str_replace('(adsbygoogle = window.adsbygoogle || []).push({});', '', $game->description);
$game->description = trim($game->description);
$sidebar = $gameBlock->filter('#sidebar')->first()->html();
preg_match ('/<b>Автор:<\/b>\s+(.*)(<\/a>)?<br>/', $sidebar, $matches);
if (count($matches) > 0) {
$game->author = strip_tags($matches[1]);
preg_match('/(.*)Теги:/', $game->author, $matches);
$game->author = $matches[1];
}
$matches = [];
preg_match ('/<b>Перевод:<\/b>\s+(.*)<\/a><br>/', $sidebar, $matches);
if (count($matches) > 0) {
$game->author .= ', пер. '.strip_tags($matches[1]);
}
return $game;
}
}