Created
August 29, 2011 20:27
-
-
Save LinuxDoku/1179315 to your computer and use it in GitHub Desktop.
Download Jamedo Songs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_GET['id'])) { | |
$trackID = (int)$_GET['id']; | |
// get download url | |
$trackUrl = file_get_contents('http://www.jamendo.com/get/track/id/track/audio/plain/'.$trackID.'/?aue=ogg2'); | |
if($trackUrl == false) { | |
echo 'track id not availible!'; | |
} else { | |
// get track information | |
$trackTitle = (string)file_get_contents('http://www.jamendo.com/get/album/id/album/title/plain/'.$trackID.'/'); | |
$trackInterpret = (string)file_get_contents('http://www.jamendo.com/get/artist/id/track/title/plain/'.$trackID.'/'); | |
$trackAlbum = (string)file_get_contents('http://www.jamendo.com/get/album/id/track/title/plain/'.$trackID.'/'); | |
$location = './'.$trackAlbum.'/'.$trackInterpret.' - '.$trackTitle; | |
if(!file_exists($trackAlbum)) { | |
mkdir($trackAlbum); | |
} | |
// download track | |
$track = file_get_contents($trackUrl); | |
file_put_contents($location.'.ogg', $track); | |
// download cover | |
$trackCoverUrl = file_get_contents('http://www.jamendo.com/get/album/id/track/artworkurl/plain/'.$trackID.'/?artwork_size=400'); | |
if($trackCoverUrl != false) { | |
file_put_contents($location.'_cover.jpg', file_get_contents($trackCoverUrl)); | |
} | |
echo 'track download finished!'; | |
} | |
} | |
echo '<p><form action="jamedo.php" method="GET"><label for="id">track id:</label> <input type="text" name="id" id="id" /><input type="submit" value="download" /></form></p>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment