Live now playing info

This commit is contained in:
2018-04-11 02:04:32 +02:00
parent 4b81347cad
commit d3bef132a4
2 changed files with 77 additions and 1 deletions

52
common/classes/Track.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
namespace Model;
class Track extends Model {
public $start;
public $itemCode;
public $title;
public $artist;
public $duration;
public $ends;
public function __construct($data) {
parent::__construct($data);
parent::ConvertToDateTime($this->start);
parent::ConvertToDateTime($this->ends);
}
private static $IDENTS = ['NIEUWSOPEN ' => 'Nieuws', 'ANWB' => 'Verkeersinformatie', 'REGIO' => 'Regionieuws', 'CB' => 'Reclame'];
public function isLayout() {
if(strlen($this->itemCode) > 0 && ($this->itemCode[0] == 'V')) {
foreach(self::$IDENTS as $ident => $display) {
if(substr($this->itemCode, 0, strlen($ident)) == $ident || substr($this->title, 0, strlen($ident)) == $ident) {
return false;
}
}
return true;
}
return false;
}
public function ends($ends = null) {
$this->ends = $ends;
}
public function secondsRemaining() {
return ($this->ends) ? ($this->ends->getTimestamp() - time()) : -1;
}
public function display() {
foreach(self::$IDENTS as $ident => $display) {
if(substr($this->itemCode, 0, strlen($ident)) == $ident || substr($this->title, 0, strlen($ident)) == $ident) {
return $display;
}
}
return $this->artist . ($this->artist ? ' - ' : '') . $this->title;
}
}