Fixes #5492 -- Send live feedback via LS.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-06-12 08:07:57 -05:00
parent 551c800337
commit aa70489286
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
2 changed files with 33 additions and 10 deletions

View File

@ -49,6 +49,16 @@ class FeedbackCommand extends AbstractCommand
Entity\Station $station,
array $payload
): Entity\SongHistory {
if ($payload['is_live']) {
return new Entity\SongHistory(
$station,
Entity\Song::createFromArray([
'artist' => $payload['artist'] ?? '',
'title' => $payload['title'] ?? '',
])
);
}
if (empty($payload['media_id'])) {
throw new RuntimeException('No payload provided.');
}

View File

@ -868,9 +868,9 @@ class ConfigWriter implements EventSubscriberInterface
def insert_missing(m) =
if m == [] then
[("title", "Live Broadcast")]
[("title", "Live Broadcast"), ("is_live", "true")]
else
m
[("is_live", "true")]
end
end
live = map_metadata(insert_missing, live)
@ -1025,18 +1025,31 @@ class ConfigWriter implements EventSubscriberInterface
# Send metadata changes back to AzuraCast
def metadata_updated(m) =
def f() =
if (m["song_id"] != "" and m["song_id"] != !last_song_id) then
last_song_id := m["song_id"]
if (m["is_live"] == "true") then
j = json()
j.add("song_id", m["song_id"])
j.add("media_id", m["media_id"])
j.add("playlist_id", m["playlist_id"])
j.add("is_live", true)
j.add("artist", m["artist"])
j.add("title", m["title"])
_ = azuracast_api_call(
"feedback",
json.stringify(j)
)
)
else
if (m["song_id"] != "" and m["song_id"] != !last_song_id) then
last_song_id := m["song_id"]
j = json()
j.add("is_live", false)
j.add("song_id", m["song_id"])
j.add("media_id", m["media_id"])
j.add("playlist_id", m["playlist_id"])
_ = azuracast_api_call(
"feedback",
json.stringify(j)
)
end
end
end