fix(legacy): add more null check in api live info

This commit is contained in:
jo 2022-01-27 11:42:14 +01:00 committed by Kyle Robbertze
parent ace167fe10
commit 86948e7b93
1 changed files with 31 additions and 12 deletions

View File

@ -303,24 +303,43 @@ class ApiController extends Zend_Controller_Action
$result = Application_Model_Schedule::GetPlayOrderRangeOld($limit);
}
if (!isset($result)) {
$this->returnJsonOrJsonp($request, []);
}
$stationUrl = Application_Common_HTTPHelper::getStationUrl();
if (($result['previous']['type'] != 'livestream') && isset($result['previous']['metadata'])) {
$previousID = $result['previous']['metadata']['id'];
$get_prev_artwork_url = $stationUrl . 'api/track?id=' . $previousID . '&return=artwork';
$result['previous']['metadata']['artwork_url'] = $get_prev_artwork_url;
if (isset($result['previous'])) {
if (
(isset($result['previous']['type']) && $result['previous']['type'] != 'livestream')
&& isset($result['previous']['metadata'])
) {
$previousID = $result['previous']['metadata']['id'];
$get_prev_artwork_url = $stationUrl . 'api/track?id=' . $previousID . '&return=artwork';
$result['previous']['metadata']['artwork_url'] = $get_prev_artwork_url;
}
}
if (($result['current']['type'] != 'livestream') && isset($result['current']['metadata'])) {
$currID = $result['current']['metadata']['id'];
$get_curr_artwork_url = $stationUrl . 'api/track?id=' . $currID . '&return=artwork';
$result['current']['metadata']['artwork_url'] = $get_curr_artwork_url;
if (isset($result['current'])) {
if (
(isset($result['current']['type']) & $result['current']['type'] != 'livestream')
&& isset($result['current']['metadata'])
) {
$currID = $result['current']['metadata']['id'];
$get_curr_artwork_url = $stationUrl . 'api/track?id=' . $currID . '&return=artwork';
$result['current']['metadata']['artwork_url'] = $get_curr_artwork_url;
}
}
if (($result['next']['type'] != 'livestream') && isset($result['next']['metadata'])) {
$nextID = $result['next']['metadata']['id'];
$get_next_artwork_url = $stationUrl . 'api/track?id=' . $nextID . '&return=artwork';
$result['next']['metadata']['artwork_url'] = $get_next_artwork_url;
if (isset($result['next'])) {
if (
(isset($result['next']['type']) && $result['next']['type'] != 'livestream')
&& isset($result['next']['metadata'])
) {
$nextID = $result['next']['metadata']['id'];
$get_next_artwork_url = $stationUrl . 'api/track?id=' . $nextID . '&return=artwork';
$result['next']['metadata']['artwork_url'] = $get_next_artwork_url;
}
}
// apply user-defined timezone, or default to station