From af0b53ff56f9c7f7ef0ab0fbf559f83d728a9dba Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Tue, 20 Oct 2020 21:53:05 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B0=D1=82=D1=8B=20=D0=BD=D0=B0=20ifict?= =?UTF-8?q?ion.ru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Sources/Ifiction.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/Sources/Ifiction.php b/app/Sources/Ifiction.php index 6f3d861..93188ea 100644 --- a/app/Sources/Ifiction.php +++ b/app/Sources/Ifiction.php @@ -38,7 +38,7 @@ class Ifiction extends Source { $text = $this->get_text('https://forum.ifiction.ru/viewforum.php?id=36'); $this->loadStr($text); unset($text); - $this->dom->filter('.GameCatalog > tbody > tr')->each(function($gameBlock) { + $this->dom->filter('.box > .inbox > .GameCatalog > tbody > tr')->each(function($gameBlock) { $href = $gameBlock->filter('.intd .tclcon a:first-child')->first(); if ($href) { $href = $href->attr('href'); @@ -47,8 +47,22 @@ class Ifiction extends Source { return; } $url = $this->baseUrl.trim($href); + if (!$this->checkPage($url)) { + return; + } + $date = NULL; + if ($gameBlock->filter('td:nth-child(3) > small.dark')->count() > 0) { + $datestring = $gameBlock->filter('td:nth-child(3) > small.dark')->text(); + if ($datestring === 'Сегодня') { + $datestring = date('d.m.Y'); + } + if ($datestring === 'Вчера') { + $datestring = date('d.m.Y', strtotime('-1 day')); + } + $date = new \DateTime($datestring); + } if ($this->checkPage($url)) { - $this->page($url); + $this->page($url, $date); } }); } @@ -57,12 +71,17 @@ class Ifiction extends Source { $is_list = (strpos($url, '&list=') !== FALSE); return $is_ifiction && !$is_list; } - public function page($url) { + public function page($url, $date = NULL) { $text = $this->get_text($url); $this->loadStr($text); unset($text); $game = new Game; $game->url = $url; + if (empty($date)) { + $game->release_date = new \DateTime(); + } else { + $game->release_date = $date; + } $game->url_discussion = $url; $temp = $this->dom->filter('div.gamecontainer div div.postmsg h1 a b span.light'); if ($temp->count() > 0) {