From 44f8f806d0d7967b6816ed0271f4592781cce0da Mon Sep 17 00:00:00 2001 From: "Buster \"Silver Eagle\" Neece" Date: Mon, 26 Nov 2018 11:38:40 -0600 Subject: [PATCH] #867 -- Post DJ/station name when a DJ first connects, overriding existing metadata. --- src/Radio/Backend/Liquidsoap.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Radio/Backend/Liquidsoap.php b/src/Radio/Backend/Liquidsoap.php index ec9e591c33..86585d14ac 100644 --- a/src/Radio/Backend/Liquidsoap.php +++ b/src/Radio/Backend/Liquidsoap.php @@ -359,6 +359,11 @@ public function writeCustomConfiguration(WriteLiquidsoapConfiguration $event) ]); } + $event->appendLines([ + '# Allow for Telnet-driven insertion of custom metadata.', + 'radio = server.insert_metadata(id="custom_metadata", radio)', + ]); + $event->appendLines([ '# Apply amplification metadata (if supplied)', 'radio = amplify(1., radio)', @@ -758,10 +763,27 @@ public function authenticateStreamer(Entity\Station $station, $user, $pass): str $streamer = $streamer_repo->authenticate($station, $user, $pass); if ($streamer instanceof Entity\StationStreamer) { - // Successful authentication: update current streamer on station. - $station->setCurrentStreamer($streamer); - $this->em->persist($station); - $this->em->flush(); + $this->logger->debug('DJ successfully authenticated.', ['username' => $user]); + + try { + // Successful authentication: update current streamer on station. + $station->setCurrentStreamer($streamer); + $this->em->persist($station); + $this->em->flush(); + + // Send custom metadata immediately to the station to fill the gap before the DJ sends their first metadata update. + $custom_metadata = [ + 'title="'.$this->_cleanUpString($streamer->getDisplayName()).'"', + 'artist="'.$this->_cleanUpString($station->getName()).'"', + ]; + $this->command($station, 'custom_metadata.insert '.implode(',', $custom_metadata)); + } catch(\Exception $e) { + $this->logger->error('Error when calling post-DJ-authentication functions.', [ + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'code' => $e->getCode(), + ]); + } return 'true'; }