Skip to content

Instantly share code, notes, and snippets.

@GianpaMX
Created March 11, 2013 09:19
Show Gist options
  • Save GianpaMX/5132995 to your computer and use it in GitHub Desktop.
Save GianpaMX/5132995 to your computer and use it in GitHub Desktop.
Script para bajar música un playlistde Corona Music. Necesitas rtmpdump y avconv Para ejecutarlo: cat response.json | php cmdownloader.php | sh Donde response.json contiene el playlist bajado de coronamusic con el firebug
<?php
$json = file_get_contents("php://stdin");
$playlist = json_decode($json);
foreach($playlist->items as $index => $item) {
$artist = $item->artistName;
$album = $item->albumTitle;
$title = $item->name;
$track = $index + 1;
$track = str_pad("$track", 2, '0', STR_PAD_LEFT);
$outputfilename = "$artist - $album - $track - $title.mp3";
/*
TODO: Bajar imagen e incrustarla en cada mp3
$image = array_pop($item->images);
$ext = pathinfo($image->url, PATHINFO_EXTENSION);
copy($image->url, "file.$ext");
*/
$url = "rtmpe://akflash.bandit.fm/ondemand/mp3:flash/srv/streamingMedia/{$item->streamingId}";
$cmd = "rtmpdump -r \"$url\" -o file.flv";
echo "$cmd\n";
$titlemetadata = "-metadata title=\"$title\"";
$authormetadata = "-metadata author=\"$artist\"";
$albummetadata = "-metadata album=\"$album\"";
$trackmetadata = "-metadata track=\"$track\"";
$cmd = "avconv -y -i file.flv -codec:a copy $titlemetadata $authormetadata $albummetadata $trackmetadata \"$outputfilename\"";
echo "$cmd\n";
$cmd = "rm -f file.flv";
echo "$cmd\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment