Skip to content

Commit

Permalink
#867 -- Post DJ/station name when a DJ first connects, overriding exi…
Browse files Browse the repository at this point in the history
…sting metadata.
  • Loading branch information
BusterNeece committed Nov 26, 2018
1 parent 8d4236c commit 44f8f80
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Radio/Backend/Liquidsoap.php
Expand Up @@ -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)',
Expand Down Expand Up @@ -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';
}
Expand Down

0 comments on commit 44f8f80

Please sign in to comment.