Prevent error where one remote can make the whole station show as offline.
This commit is contained in:
parent
309bc50b93
commit
acd94115b9
|
@ -2,11 +2,11 @@
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Logger;
|
||||
use App\Settings;
|
||||
use App\Utilities;
|
||||
use App\Xml\Reader;
|
||||
use App\Xml\Writer;
|
||||
use App\Logger;
|
||||
use NowPlaying\Adapter\AdapterAbstract;
|
||||
use NowPlaying\Exception;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
@ -41,8 +41,6 @@ class Icecast extends AbstractFrontend
|
|||
$include_clients ? $np_adapter->getClients($mount->getName(), true) : null
|
||||
);
|
||||
}
|
||||
|
||||
Logger::getInstance()->debug('Aggregated NowPlaying response', ['response' => $np_final]);
|
||||
} catch (Exception $e) {
|
||||
Logger::getInstance()->error(sprintf('NowPlaying adapter error: %s', $e->getMessage()));
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Logger;
|
||||
use App\Settings;
|
||||
use App\Utilities;
|
||||
use App\Logger;
|
||||
use NowPlaying\Adapter\AdapterAbstract;
|
||||
use NowPlaying\Adapter\SHOUTcast2;
|
||||
use NowPlaying\Exception;
|
||||
|
@ -75,8 +75,6 @@ class SHOUTcast extends AbstractFrontend
|
|||
$include_clients ? $np_adapter->getClients($sid, true) : null
|
||||
);
|
||||
}
|
||||
|
||||
Logger::getInstance()->debug('Aggregated NowPlaying response', ['response' => $np_final]);
|
||||
} catch (Exception $e) {
|
||||
Logger::getInstance()->error(sprintf('NowPlaying adapter error: %s', $e->getMessage()));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use GuzzleHttp\Client;
|
|||
use GuzzleHttp\Psr7\Uri;
|
||||
use Monolog\Logger;
|
||||
use NowPlaying\Adapter\AdapterAbstract;
|
||||
use NowPlaying\Exception;
|
||||
|
||||
abstract class AbstractRemote
|
||||
{
|
||||
|
@ -106,7 +105,7 @@ abstract class AbstractRemote
|
|||
$np,
|
||||
null
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error(sprintf('NowPlaying adapter error: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
|
@ -162,8 +161,10 @@ abstract class AbstractRemote
|
|||
$np_aggregate['meta'] = $np['meta'];
|
||||
}
|
||||
|
||||
$np_aggregate['listeners']['clients'] = array_merge((array)$np_aggregate['listeners']['clients'],
|
||||
(array)$np['listeners']['clients']);
|
||||
$np_aggregate['listeners']['clients'] = array_merge(
|
||||
(array)$np_aggregate['listeners']['clients'],
|
||||
(array)$np['listeners']['clients']
|
||||
);
|
||||
$np_aggregate['listeners']['current'] += $np['listeners']['current'];
|
||||
$np_aggregate['listeners']['unique'] += $np['listeners']['unique'];
|
||||
$np_aggregate['listeners']['total'] += $np['listeners']['total'];
|
||||
|
|
|
@ -222,6 +222,12 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
|
|||
$np_raw = AdapterAbstract::NOWPLAYING_EMPTY;
|
||||
}
|
||||
|
||||
$this->logger->debug('Final NowPlaying Response for Station', [
|
||||
'id' => $station->getId(),
|
||||
'name' => $station->getName(),
|
||||
'np' => $np_raw,
|
||||
]);
|
||||
|
||||
$np = new Entity\Api\NowPlaying;
|
||||
$uri_empty = new Uri('');
|
||||
|
||||
|
@ -402,8 +408,11 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
|
|||
|
||||
// Loop through all remotes and update NP data accordingly.
|
||||
foreach ($event->getRemotes() as $ra_proxy) {
|
||||
$np_raw = $ra_proxy->getAdapter()->updateNowPlaying($ra_proxy->getRemote(), $np_raw,
|
||||
$event->includeClients());
|
||||
$np_raw = $ra_proxy->getAdapter()->updateNowPlaying(
|
||||
$ra_proxy->getRemote(),
|
||||
$np_raw,
|
||||
$event->includeClients()
|
||||
);
|
||||
}
|
||||
|
||||
$event->setRawResponse($np_raw);
|
||||
|
|
Loading…
Reference in New Issue