Fixes #5553 -- Fix bugs with live streamer and NowPlaying API responses.
This commit is contained in:
parent
3716eef54a
commit
1e8b45803a
|
@ -6,7 +6,7 @@ namespace App\Entity\ApiGenerator;
|
||||||
|
|
||||||
use App\Entity;
|
use App\Entity;
|
||||||
use App\Http\Router;
|
use App\Http\Router;
|
||||||
use App\Radio\Enums\BackendAdapters;
|
use App\Utilities\Logger;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GuzzleHttp\Psr7\Uri;
|
use GuzzleHttp\Psr7\Uri;
|
||||||
use NowPlaying\Result\CurrentSong;
|
use NowPlaying\Result\CurrentSong;
|
||||||
|
@ -35,7 +35,9 @@ class NowPlayingApiGenerator
|
||||||
): Entity\Api\NowPlaying\NowPlaying {
|
): Entity\Api\NowPlaying\NowPlaying {
|
||||||
$baseUri = new Uri('');
|
$baseUri = new Uri('');
|
||||||
|
|
||||||
if (empty($npResult->currentSong->text)) {
|
$updateSongFromNowPlaying = !$station->getBackendTypeEnum()->isEnabled();
|
||||||
|
|
||||||
|
if ($updateSongFromNowPlaying && empty($npResult->currentSong->text)) {
|
||||||
return $this->offlineApi($station, $baseUri);
|
return $this->offlineApi($station, $baseUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +51,6 @@ class NowPlayingApiGenerator
|
||||||
unique: $npResult->listeners->unique
|
unique: $npResult->listeners->unique
|
||||||
);
|
);
|
||||||
|
|
||||||
$updateSongFromNowPlaying = (BackendAdapters::Liquidsoap !== $station->getBackendTypeEnum());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sh_obj = $this->historyRepo->updateFromNowPlaying(
|
$sh_obj = $this->historyRepo->updateFromNowPlaying(
|
||||||
$station,
|
$station,
|
||||||
|
@ -59,7 +59,9 @@ class NowPlayingApiGenerator
|
||||||
? Entity\Song::createFromNowPlayingSong($npResult->currentSong)
|
? Entity\Song::createFromNowPlayingSong($npResult->currentSong)
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
} catch (Exception) {
|
} catch (Exception $e) {
|
||||||
|
Logger::getInstance()->error($e->getMessage(), ['exception' => $e]);
|
||||||
|
|
||||||
return $this->offlineApi($station, $baseUri);
|
return $this->offlineApi($station, $baseUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ class NowPlayingApiGenerator
|
||||||
route_name: 'api:stations:streamer:art',
|
route_name: 'api:stations:streamer:art',
|
||||||
route_params: [
|
route_params: [
|
||||||
'station_id' => $station->getIdRequired(),
|
'station_id' => $station->getIdRequired(),
|
||||||
'streamer_id' => $currentStreamer->getIdRequired() . '|' . $currentStreamer->getArtUpdatedAt(),
|
'id' => $currentStreamer->getIdRequired() . '|' . $currentStreamer->getArtUpdatedAt(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ class SongApiGenerator
|
||||||
route_name: 'api:stations:streamer:art',
|
route_name: 'api:stations:streamer:art',
|
||||||
route_params: [
|
route_params: [
|
||||||
'station_id' => $station->getIdRequired(),
|
'station_id' => $station->getIdRequired(),
|
||||||
'streamer_id' => $currentStreamer->getIdRequired() . '|' . $currentStreamer->getArtUpdatedAt(),
|
'id' => $currentStreamer->getIdRequired() . '|' . $currentStreamer->getArtUpdatedAt(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,12 @@ final class SongHistoryRepository extends AbstractStationBasedRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$newCurrentSong->setTimestampStart(time());
|
$newCurrentSong->setTimestampStart(time());
|
||||||
|
|
||||||
|
$currentStreamer = $station->getCurrentStreamer();
|
||||||
|
if (null !== $currentStreamer) {
|
||||||
|
$newCurrentSong->setStreamer($currentStreamer);
|
||||||
|
}
|
||||||
|
|
||||||
$this->em->persist($newCurrentSong);
|
$this->em->persist($newCurrentSong);
|
||||||
|
|
||||||
$station->setCurrentSong($newCurrentSong);
|
$station->setCurrentSong($newCurrentSong);
|
||||||
|
|
|
@ -51,12 +51,18 @@ class FeedbackCommand extends AbstractCommand
|
||||||
array $payload
|
array $payload
|
||||||
): Entity\SongHistory {
|
): Entity\SongHistory {
|
||||||
if (isset($payload['artist'])) {
|
if (isset($payload['artist'])) {
|
||||||
|
$newSong = Entity\Song::createFromArray([
|
||||||
|
'artist' => $payload['artist'] ?? '',
|
||||||
|
'title' => $payload['title'] ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$this->historyRepo->isDifferentFromCurrentSong($station, $newSong)) {
|
||||||
|
throw new RuntimeException('Song is not different from current song.');
|
||||||
|
}
|
||||||
|
|
||||||
return new Entity\SongHistory(
|
return new Entity\SongHistory(
|
||||||
$station,
|
$station,
|
||||||
Entity\Song::createFromArray([
|
$newSong
|
||||||
'artist' => $payload['artist'] ?? '',
|
|
||||||
'title' => $payload['title'] ?? '',
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ class ConfigWriter implements EventSubscriberInterface
|
||||||
|
|
||||||
def metadata_updated(m) =
|
def metadata_updated(m) =
|
||||||
def f() =
|
def f() =
|
||||||
if (m["title"] != !last_title and m["artist"] != !last_artist) then
|
if (m["title"] != !last_title or m["artist"] != !last_artist) then
|
||||||
last_title := m["title"]
|
last_title := m["title"]
|
||||||
last_artist := m["artist"]
|
last_artist := m["artist"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue