Updated helios and multikino classes and interface they are implementing.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Paper\CinemaHelios;
|
||||
use App\Paper\CinemaMultikino;
|
||||
use DiDom\Document;
|
||||
use App\Paper\Paper;
|
||||
@@ -10,7 +11,7 @@ class Repertoire extends Controller
|
||||
{
|
||||
|
||||
private $main;
|
||||
private $icon = '/small/film.png';
|
||||
private $icon = 'film';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -22,7 +23,7 @@ class Repertoire extends Controller
|
||||
{
|
||||
$date = date('d/m/Y');
|
||||
$repertuarText = $this->cinemacityRepertuar($date);
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon, $this->icon);
|
||||
// $this->main->sendPrint('', $repertuarText, $this->icon, $this->icon);
|
||||
return back();
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ class Repertoire extends Controller
|
||||
$date = new \DateTime();
|
||||
$date->modify('+1 day');
|
||||
$repertuarText = $this->cinemacityRepertuar($date->format('d/m/Y'));
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon, $this->icon);
|
||||
// $this->main->sendPrint('', $repertuarText, $this->icon, $this->icon);
|
||||
return back();
|
||||
}
|
||||
|
||||
@@ -58,51 +59,50 @@ class Repertoire extends Controller
|
||||
}
|
||||
|
||||
|
||||
private function multikinoRepertuar($date)
|
||||
{
|
||||
|
||||
$text = '';
|
||||
$repertuar = json_decode(file_get_contents('https://multikino.pl/pl/repertoire/cinema/seances?id=4&from=' . $date));
|
||||
$text .= "Repertuar Multikino Gdańsk\n";
|
||||
$text .= $date . "\n\n";
|
||||
|
||||
foreach ($repertuar->results as $movie) {
|
||||
$text .= $movie->title . "\n";
|
||||
$text .= $movie->print_version . "\n";
|
||||
|
||||
$hours = [];
|
||||
foreach ($movie->seances as $seans) {
|
||||
$hours[] = date('H:i', strtotime($seans->beginning_date));
|
||||
}
|
||||
$text .= implode(', ', $hours) . "\n\n";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
// private function multikinoRepertuar($date)
|
||||
// {
|
||||
//
|
||||
// $text = '';
|
||||
// $repertuar = json_decode(file_get_contents('https://multikino.pl/pl/repertoire/cinema/seances?id=4&from=' . $date));
|
||||
// $text .= "Repertuar Multikino Gdańsk\n";
|
||||
// $text .= $date . "\n\n";
|
||||
//
|
||||
// foreach ($repertuar->results as $movie) {
|
||||
// $text .= $movie->title . "\n";
|
||||
// $text .= $movie->print_version . "\n";
|
||||
//
|
||||
// $hours = [];
|
||||
// foreach ($movie->seances as $seans) {
|
||||
// $hours[] = date('H:i', strtotime($seans->beginning_date));
|
||||
// }
|
||||
// $text .= implode(', ', $hours) . "\n\n";
|
||||
// }
|
||||
//
|
||||
// return $text;
|
||||
// }
|
||||
|
||||
public function today_multikino()
|
||||
{
|
||||
$multikino = new CinemaMultikino();
|
||||
|
||||
$repertuarText = $multikino->convertToPrint(date('Y-m-d'), 4);
|
||||
$multikino->setCinemaId(4);
|
||||
$multikino->setDay(date('Y-m-d'));
|
||||
|
||||
$repertuarText = $multikino->convertToPrint();
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function tomorrow_multikino()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
$date->modify('+1 day');
|
||||
|
||||
$multikino = new CinemaMultikino();
|
||||
$repertuarText = $multikino->convertToPrint($date->format('Y-m-d'), 4);
|
||||
$multikino->setDay(date_create()->modify('+1 day')->format('Y-m-d'));
|
||||
$multikino->setCinemaId(4);
|
||||
|
||||
$repertuarText = $multikino->convertToPrint();
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
return back();
|
||||
|
||||
|
||||
// $repertuarText = $this->multikinoRepertuar($date->format('Y-m-d'));
|
||||
// $this->main->sendPrint('', $repertuarText);
|
||||
// return back();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class Repertoire extends Controller
|
||||
$date->modify('+1 day');
|
||||
|
||||
$repertuarText = $this->gdynskieCentrumFilmowe($date->format('d_m_Y'));
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
// $this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
return back();
|
||||
}
|
||||
|
||||
@@ -126,15 +126,28 @@ class Repertoire extends Controller
|
||||
|
||||
public function today_helios()
|
||||
{
|
||||
$this->main->sendPrint('', $this->helios(0, 2), $this->icon);
|
||||
$this->main->sendPrint('', $this->helios(0, 49));
|
||||
|
||||
$helios = new CinemaHelios();
|
||||
$helios->setDay(0);
|
||||
$helios->setCinemaId([2, 49]);
|
||||
$helios->convertToPrint();
|
||||
|
||||
$repertuarText = $helios->convertToPrint();
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function tomorrow_helios()
|
||||
{
|
||||
$this->main->sendPrint('', $this->helios(1, 2), $this->icon);
|
||||
$this->main->sendPrint('', $this->helios(1, 49));
|
||||
$helios = new CinemaHelios();
|
||||
$helios->setDay(1);
|
||||
$helios->setCinemaId([2, 49]);
|
||||
$helios->convertToPrint();
|
||||
|
||||
$repertuarText = $helios->convertToPrint();
|
||||
$this->main->sendPrint('', $repertuarText, $this->icon);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
@@ -157,40 +170,6 @@ class Repertoire extends Controller
|
||||
$this->tomorrow_gdynskiecentrumfilmowe();
|
||||
}
|
||||
|
||||
private function helios($day, $cinemaId)
|
||||
{
|
||||
$url = 'http://www.helios.pl/2,Gdansk/Repertuar/axRepertoire/?dzien=' . $day . '&kino=' . $cinemaId;
|
||||
|
||||
|
||||
$data = json_decode(file_get_contents($url));
|
||||
$document = new Document();
|
||||
$data->html = str_replace(["\n", "\t"], '', $data->html);
|
||||
$document->loadHtml($data->html);
|
||||
|
||||
|
||||
$cinemas = [2 => 'Helios Alfa', 49 => 'Helios Metropolia'];
|
||||
|
||||
$text = '';
|
||||
$text .= "Repertuar $cinemas[$cinemaId]\n";
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->modify('+' . $day . ' day');
|
||||
|
||||
$text .= $date->format('d-m-Y') . "\n\n";
|
||||
|
||||
|
||||
foreach ($document->find('.seance') as $seans) {
|
||||
$text .= trim($seans->find('.movie-title')[0]->text()) . "\n";
|
||||
$hours = [];
|
||||
foreach ($seans->find('.time li') as $hour) {
|
||||
$hours[] = $hour->text();
|
||||
}
|
||||
$text .= implode(', ', array_unique($hours)) . "\n\n";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
private function gdynskieCentrumFilmowe($date)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user