Skip to content

Commit

Permalink
Code cleanup and add multi audio tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Aug 2, 2024
1 parent 6d9dbac commit 71c4919
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 129 deletions.
8 changes: 4 additions & 4 deletions app/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class Channel extends Model
//
protected $fillable = ['name', 'service', 'position', 'picon'];

protected $appends = array('currentprogram', 'nextprogram', 'is_hd', 'is_4k');
protected $appends = ['currentprogram', 'nextprogram', 'is_hd', 'is_4k'];

private $now_next;

// Caching function to get the data only once from the database...
private function get_now_and_next_programs()
private function getNowAndNextPrograms()
{
$this->now_next = ['now' => null, 'next' => null];
$programs = $this->programs()->where('stop', '>', Carbon::now())->limit(2)->get();
Expand All @@ -33,15 +33,15 @@ private function get_now_and_next_programs()
public function getCurrentProgramAttribute()
{
if (! isset($this->now_next)) {
$this->get_now_and_next_programs();
$this->getNowAndNextPrograms();
}
return $this->now_next['now'];
}

public function getNextProgramAttribute()
{
if (! isset($this->now_next)) {
$this->get_now_and_next_programs();
$this->getNowAndNextPrograms();
}
return $this->now_next['next'];

Expand Down
22 changes: 2 additions & 20 deletions app/Dreambox.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ private function zap_first($source)
'timeout' => $this->guzzle_http_timeout,
]);

// if (config('app.debug'))
// {
// start_measure('zap_first','Zapping Dreambox to right channel');
// }
try {
$start = microtime(true);
$response = $client->request('GET', '/api/zap', [
Expand All @@ -64,10 +60,7 @@ private function zap_first($source)
$this->status = null;
return false;
}
// if (config('app.debug'))
// {
// stop_measure('zap_first');
// }

return 200 == $response->getStatusCode();
}

Expand All @@ -77,10 +70,7 @@ private function load_playlist($source)
'base_uri' => 'http://' . $this->hostname . ':' . $this->port,
'timeout' => $this->guzzle_http_timeout,
]);
// if (config('app.debug'))
// {
// start_measure('load_playlist','Get streaming url from playlist');
// }

try {
if ($source instanceof Channel) {
$response = $client->request('GET', '/web/stream.m3u', [
Expand Down Expand Up @@ -124,10 +114,6 @@ public function is_online()
'timeout' => $this->guzzle_http_timeout,
]);

// if (config('app.debug'))
// {
// start_measure('is_online','Dreambox online check');
// }
try {
$start = microtime(true);
$response = $client->request('GET', '/api/about', ['auth' => [$this->username, $this->password]]);
Expand All @@ -140,10 +126,6 @@ public function is_online()
$this->status = null;
return false;
}
// if (config('app.debug'))
// {
// stop_measure('is_online');
// }

if (200 == $response->getStatusCode()) {
try {
Expand Down
4 changes: 2 additions & 2 deletions app/Program.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Program extends Model
{
protected $fillable = ['epg_id', 'name', 'start', 'stop', 'description'];

protected $appends = array('duration');
protected $appends = ['duration'];

public function getdurationAttribute()
public function getDurationAttribute()
{
return $this->stop->diffInSeconds($this->start);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Recording.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Recording extends Model
protected $fillable = ['name', 'service', 'start', 'stop', 'description', 'filesize'];


protected $appends = array('duration');
protected $appends = ['duration'];

public function getdurationAttribute()
public function getDurationAttribute()
{
return $this->stop->diffInSeconds($this->start);
}
Expand Down
Loading

0 comments on commit 71c4919

Please sign in to comment.