Skip to content

Instantly share code, notes, and snippets.

@monbro
Created November 23, 2012 08:44
Show Gist options
  • Save monbro/4134596 to your computer and use it in GitHub Desktop.
Save monbro/4134596 to your computer and use it in GitHub Desktop.
Grab (and Download) latest MP3 Locations from FM4 Unlimited / Soundpark
$urls = array ("http://onapp1.orf.at/webcam/fm4/fod/unlimited.xspf",
"http://onapp1.orf.at/webcam/fm4/fod/soundpark.xspf");
function downloadFile ($url, $path) {
$newfname = $path;
$file = fopen ($url, "rb");
if ($file) {
$newf = fopen ($newfname, "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
}
function grabfile($url) {
$xml = simplexml_load_file($url);
foreach($xml->trackList->track as $track) {
$podcast[] = array(
'mp3' => (string)$track->location,
'img' => (string)$track->image,
'title' => (string)$track->title
);
// Download Episode if wanted, make sure apache user can write in dir 'dl'
// to download uncomment
// downloadFile((string)$track->location,'dl/'.basename((string)$track->location));
}
return $podcast;
}
foreach($urls as $url) {
$podcasts[] = grabfile($url);
}
// Get Arrays with all episodes available
// var_dump($podcasts);
@monbro
Copy link
Author

monbro commented Oct 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment