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

问题描述 投票:0回答:2

我有一个从 Soundcloud 获取歌曲的网站。我的问题是,所有下载的文件都有像 aline 这样的名称! 例如,如果我下载/获取文件“我独自行走 - green 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)){
php soundcloud
2个回答
0
投票

您只需重命名文件名即可。然后在您的代码中,只需将旧文件名替换为您刚刚创建的新文件名即可。


0
投票

为了确保下载的文件保持原来的名称而不是被重命名为无法识别的名称,您需要修改您的下载机制。这通常涉及设置适当的标头来指定所需的文件名。

这是代码片段的修订版本,包括设置正确文件名所需的标头:

    <?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[

我也运行一个类似的 sonudcloud 到 mp3 网站

© www.soinside.com 2019 - 2024. All rights reserved.