Fetch and prepare ö1 Metadata for streamripper
Posted: Fri Nov 11, 2011 9:19 pm
[PROBLEM]
The Austrian radio channel "Ö1" sends confusing title metadata within their live streams.
[SOLUTION]
After reading the source code of their streaming website, it was clear that the URL http://oe1.orf.at/programm/konsole/live contains the currently running title (and a few of the subsequent ones), encoded in JSON format.
One can now simply use plain-vanilla PHP, and transform the JSON data into something that, for example, streamripper can read:
NOTE: It's important that the script continuously refreshes the metadata itself - therefore the infinite "while" loop, and the $PAUSE sleep.
If you save the PHP code above in a file called "metadata-oe1.php", you can call streamripper like this:
The Austrian radio channel "Ö1" sends confusing title metadata within their live streams.
[SOLUTION]
After reading the source code of their streaming website, it was clear that the URL http://oe1.orf.at/programm/konsole/live contains the currently running title (and a few of the subsequent ones), encoded in JSON format.
One can now simply use plain-vanilla PHP, and transform the JSON data into something that, for example, streamripper can read:
Code: Select all
#!/usr/bin/php
<?php
$PAUSE=3; // Wait n seconds before refreshing the metadata
$METADATA_URL="http://oe1.orf.at/programm/konsole/live";
while(true)
{
// Fetch stream metadata in JSON format from OE1 website:
$json_string = file_get_contents($METADATA_URL);
// Parse JSON data into PHP object:
$json_data = json_decode($json_string);
$current_track = $json_data->list[0];
printf("TITLE=(%s) %s\nARTIST=OE1 [ID:%d]\n.\n",
trim($current_track->time),
$current_track->title,
$current_track->id
);
sleep($PAUSE);
}
?>
If you save the PHP code above in a file called "metadata-oe1.php", you can call streamripper like this:
Code: Select all
streamripper http://mp3stream3.apasf.apa.at:8000/listen.pls -d /srv/streamripper/OE1 -E /path/to/metadata-oe1.php