从标签,获取标签的SoundCloud下载音乐

时间:2014-09-28 22:17:49

标签: php soundcloud

我有一个从Soundcloud抓起歌曲的网站。我的问题是,所有下载的文件都有像aline这样的名字! 例如,如果我下载/获取文件“我独行 - 绿色day.mp3”,下载后它看起来像bybbydsbaubx.mp3。怎么办呢?我只需要歌曲名称,因为我的所有用户都很困惑。

以下是我网页代码的示例。

 <?php





include'func.php';
$id=$_GET['id'];
$grab=json_decode(ngegrab('http://api.soundcloud.com/tracks/'.$id.'.json?client_id=c435ec96ae345d5ce32496d339fc291d'));
$duration=format_time($grab->duration/1000);
if(!empty($grab->genre)){
$genre=$grab->genre;
}else{
$genre='Unknown';
}
$name=$grab->title;
$size=format_size(getfilesize(getlinkdl($id)));
if(!empty($name) && !empty($_GET['id']) && !empty($_GET['permalink'])){
$title='Download '.$name.' ('.$size.')';
include'headl.php';
echo'<div class=title align=justify><span xmlns:v="http://rdf.data-vocabulary.org/#"><span typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">Home</a></span> &#187; <span typeof="v:Breadcrumb"><a href="/?genre='.$genre.'" rel="v:url" property="v:title">'.$genre.'</a></span> &#187; <span typeof="v:Breadcrumb"><span class="breadcrumb_last" property="v:title">'.$title.'</span></span></span></div><div class="menu"><div class="ml"><b>Download '.$name.'.mp3</b></div><div class="ml">Genre: <a href="/?genre='.$genre.'">'.$genre.'</a></div><div class="ml">Duration: '.$duration.'</div><div class="ml">Size: '.$size.'</div><div class="ml">Bitrate: 128 kbps</div></div>';
$permexp=explode('-',$grab->permalink);
echo'<div class="list">Tag: ';
foreach($permexp as $perma){
echo'<a href="/?q='.$perma.'">'.ucfirst($perma).'</a>, ';
}

$ttag=clearspace($genre);
$tgrab=json_decode(ngegrab('http://ws.audioscrobbler.com/2.0/?method=tag.getsimilar&tag='.strtolower($ttag).'&api_key=7df2ba528dcd0d495e3db6284ee6e1a3&format=json'));
$tjumlah=count($tgrab->similartags->tag)-1;
if($tjumlah < 4){
$tcount=$tjumlah;
}else{
$tcount='3';
}
if(!empty($tgrab->similartags->tag[0]->name)){
echo'</div><div class="list">Other Genre';
for($i=0;$i<=$tcount;$i++){
echo'<a href="/?genre='.$tgrab->similartags->tag[$i]->name.'">'.$tgrab->similartags->tag[$i]->name.'</a>, ';
}

}
echo'</div><div class=green align=center><a href="'.getlinkdl($id).'" rel="nofollow"><img src="/download.gif"></a><br/><a href="'.getlinkdl($id).'" rel="nofollow"><b>Download '.$name.'.mp3</b></a><br/></div>';
$genrer=str_replace(' ',',',$genre);
$genrer=str_replace('_',',',$genrer);
$genrer=str_replace('-',',',$genrer);
$jsonr=json_decode(ngegrab('http://api.soundcloud.com/tracks.json?genres='.strtolower($genrer).'&limit=8&offset=0&client_id=c435ec96ae345d5ce32496d339fc291d'));
if (!empty($jsonr[0]->title)){

1 个答案:

答案 0 :(得分:0)

您可以重命名文件名。然后在您的代码上,只需用您刚创建的新文件名替换旧文件名。