添加SongTaste音乐外链app
作者:matrix 被围观: 2,328 次 发布时间:2013-09-24 分类:兼容并蓄 | 无评论 »
这是一个创建于 3264 天前的主题,其中的信息可能已经有所发展或是发生改变。
SongTaste已经不复存在~
转换地址: http://link.hhtjim.com
songtaste.com的音乐打开速度是比较快的,比起百度网盘就songtaste和xiaomi的速度很理想,外链起来比较不错。
网上找了很多SongTaste外链的方法,大多数都是pc端程序,没看到什么php源码之类的东西,很是蛋疼。
so ,也学着看看播放页面的源代码,结果找到了外链的方法。 哈哈。
代码语言:javascript复制打开播放页面会看到有http://image.songtaste.com/inc/main.js这样的js代码,其中的有关代码是改写mp3文件信息的:
//重新改写开始
function GetSongType(md5code)
{
switch(md5code)
{
case "7d99bb4c7bd4602c342e2bb826ee8777":
return ".wma";
break;
case "25e4f07f5123910814d9b8f3958385ba":
return ".Wma";
break;
case "51bbd020689d1ce1c845a484995c0cce":
return ".WMA";
break;
case "b3a7a4e64bcd8aabe4cabe0e55b57af5":
return ".mp3";
break;
case "d82029f73bcaf052be8930f6f4247184":
return ".MP3";
break;
case "5fd91d90d9618feca4740ac1f2e7948f":
return ".Mp3";
break;
}
}
//Media Link
function playmedia1(playIcon, strID,strURL,intWidth,intHeight,type, Head,st_songid,t) {
playIcon.replace(" "," ");
strID.replace(" "," ");
var objDiv=document.getElementById(strID);
document.getElementById(playIcon).style.display='none';
if (!objDiv) return false;
if (objDiv.style.display!='none') {
objDiv.innerHTML='';
objDiv.style.display='none';
} else {
if(strURL.indexOf('rayfile')>0) {
var SongUrl = Head strURL GetSongType(type);
objDiv.innerHTML=makemedia_html(SongUrl,intWidth,intHeight);
objDiv.style.display='block';
} else {
$.ajax({
type:'POST',
url:'/time.php',
cache:false,
data:'str=' strURL '&sid=' st_songid '&t=' t,
dataType:'html',
success:function(data){
//alert(data);
if(data){
objDiv.innerHTML=makemedia_html(data,intWidth,intHeight);
objDiv.style.display='block';
if(data.indexOf('duomi.com') > 0){
$("#show_logo").show();
}
}
},
error:function(data){
//alert('error');
}
});
}
}
}
//Media Build
function makemedia_html (SongUrl,intWidth,intHeight) {
var strHtml ="<object id='MediaPlayer1' width='" intWidth "' height='" intHeight "' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715' align='baseline' border='0' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
strHtml ="<param name='invokeURLs' value='0'>";
strHtml ="<param name='AutoRewind' value='1'>";
strHtml ="<param name='FileName' value="" SongUrl "">";
strHtml ="<param name='ShowControls' value='1'>";
strHtml ="<param name='ShowPositionControls' value='0'>";
strHtml ="<param name='ShowAudioControls' value='1'>";
strHtml ="<param name='ShowTracker' value='1'>";
strHtml ="<param name='ShowDisplay' value='0'>";
strHtml ="<param name='ShowStatusBar' value='1'>";
strHtml ="<param name='AutoSize' value='0'>";
strHtml ="<param name='ShowGotoBar' value='0'>";
strHtml ="<param name='ShowCaptioning' value='0'>";
strHtml ="<param name='AutoStart' value='1'>";
strHtml ="<param name='PlayCount' value='100'>";
strHtml ="<param name='AnimationAtStart' value='0'>";
strHtml ="<param name='TransparentAtStart' value='0'>";
strHtml ="<param name='AllowScan' value='0'>";
strHtml ="<param name='EnableContextMenu' value='1'>";
strHtml ="<param name='ClickToPlay' value='0'>";
strHtml ="<param name='DefaultFrame' value='datawindow'>";
strHtml ="<embed src="" SongUrl "" align='baseline' border='0' width='" intWidth "' height='" intHeight "' type='application/x-mplayer2'";
strHtml =" pluginspage='http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=media&sba=plugin&'";
strHtml ="name='MediaPlayer' showcontrols='1' showpositioncontrols='0' showaudiocontrols='1' showtracker='1' showdisplay='0' showstatusbar='1' autosize='0' showgotobar='0' showcaptioning='0' autostart='1' autorewind='1'";
strHtml ="animationatstart='0' transparentatstart='0' allowscan='1' enablecontextmenu='1' clicktoplay='0' defaultframe='datawindow' invokeurls='0' playcount='100'> </embed></object>";
return strHtml;
}
function wrtSongLink(strURL,intWidth,intHeight,type, Head)
{
SongUrl = Head strURL GetSongType(type);
if(SongUrl.length > 35)
SongUrl1 = SongUrl.slice(0,24) "......" SongUrl.slice(-10)
else
SongUrl1 = SongUrl
document.write("下载地址 <a href='" SongUrl "'>" SongUrl1 "</a>")
//document.write("<a href="#" onclick="window.open('" Head strURL GetSongType(type) "','','width=0,height=0,top=0,left=0');">点此下载</a>")
}
//重新改写结束
代码语言:javascript复制还有播放页面源代码的<script>:
<script>
var flashvars = {};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
wmode: "transparent"
};
params.allowScriptAccess = "always";
params.hasPriority = "true";
params.swliveconnect = "true";
var attributes = {
id: "STWebPlayer"
};
swfobject.embedSWF("/stflashplayer/STPlayer_1.10.swf", "STWebPlayer", "360", "70", "10.0.0", "/stflashplayer/expressInstall.swf", flashvars, params, attributes);
function swfReady() {
var strURL = "3fa754e9c0064b06c4737445855dc9b16fd3603796f3703440677bdc89365656ecf18f4d2c63d2c42f1ced3fe51ffc51";
var Head = "http://m4.";
var type = "b3a7a4e64bcd8aabe4cabe0e55b57af5";
var iscopy = "0";
if (strURL.indexOf('rayfile') > 0 && iscopy <= 0) {
var SongUrl = Head strURL GetSongType(type);
var obj = {
name: "鲸鱼的童话",
url: SongUrl,
isShowLogo: "0",
isAutoReplay: 1,
isAutoPlay: 0
};
setSongInfo(obj);
}
flashplay("3fa754e9c0064b06c4737445855dc9b16fd3603796f3703440677bdc89365656ecf18f4d2c63d2c42f1ced3fe51ffc51", "1752907", "0");
ListenLog("1752907", "0");
}
function setSongInfo(obj) {
try {
var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");
stPlayerSWFobj.setSongInfo(obj);
} catch(e) {
alert(e.description);
}
}
function playAudio() {
var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");
stPlayerSWFobj.playAudio();
}
function pauseAudio() {
var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");
stPlayerSWFobj.pauseAudio();
}
function playerPlayStart() {}
function playerPaused() {}
function flashplay(strURL, st_songid, t) {
$.ajax({
type: 'POST',
url: '/time.php',
cache: false,
data: 'str=' strURL '&sid=' st_songid '&t=' t,
dataType: 'html',
success: function(data) {
if (data) {
var obj = {
name: "鲸鱼的童话",
url: data,
isShowLogo: "0",
isAutoReplay: 1,
isAutoPlay: 0
};
setSongInfo(obj);
if (data.indexOf('duomi.com') > 0) {
$("#show_logo").show();
}
}
},
error: function(data) {}
});
}
</script>
结果没看到怎样还原加密的信息,不过发现了SongTaste音乐外链的基本方法和官方接口:/time.php
time.php的参数str值就是上面33行处的3fa754e9c0064b06c4737445855dc9b16fd3603796f3703440677bdc89365656ecf18f4d2c63d2c42f1ced3fe51ffc51这东东。
形如:/time.php?str=3fa754e9c0064b06c4737445855dc9b16fd3603796f3703440677bdc89365656ecf18f4d2c63d2c42f1ced3fe51ffc51
之后会返回随时间变化的外链地址,形如:
http//m4.songtaste.com/201309232330/57630f6a60a2534c0221a4783b5a9f4c/4/40/40e746ed9ca918b0f8a4322f5fd87c70.mp3
原理:
SongTaste音乐外链原理也就用php的preg_match_all函数正则匹配提取【var strURL = "】和【;/】之间的字符串,之后用substr(抓取其中你需要的值。这就取得了那一串串加密后的东东。然后再利用的time.php?tr=取得暂时的外链地址。
提供外链接口形如:https://www.hhtjim.com/songtaste.php?url=http://www.songtaste.com/song/2932328/
再弄个链接转换的html或者php,例如http://d.hhtjim.com/st.php,界面那就是高端大气上档次!
之后结合伪静态那就实现了完全外链,也就没有时间限制了。因为每次使用的都是静态外链地址(形如:https://www.hhtjim.com/st/516159.mp3),之后php会根据目前此时的post来获取外链地址,也就不会有过期的说法了。
伪静态:
代码语言:javascript复制RewriteRule ^st/([0-9] ).mp3?$ /songtaste.php?url=http://songtaste.com/song/$1 [L]
下面外链测试:http://www.songtaste.com/song/1999664/
外链转换地址:http://d.hhtjim.com/st.php 亲自试试~
转换地址:http://link.hhtjim.com
个人问题,代码有错误的话还请指正!
10-6添加另外的抓取方法,大同小异。
又用到强大的curl, post提交
代码语言:javascript复制set_time_limit(0);//为0时:允许脚本运行的时间无上限。不设置此函数的话默认为30s
$song_id = '1051120';//mp3id
$url = 'http://songtaste.com/play.php?song_id='.$song_id;
$con = file_get_contents($url);
preg_match('/", "([0-9a-z] )"\);/i',$con,$match);
$str = $match[1];
$url='http://songtaste.com/time.php';
$curlPost="str=".$str."&sid=".$song_id;
$ch = curl_init();//初始化curl
curl_setopt($ch,CURLOPT_URL, $url);//提交到指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
print_r($data);//输出结果
来自:php curl 取链接地址
发现http://songtaste.com/play.php?song_id=1051120[源码](https://www.hhtjim.com/tag/源码)里有个mp3地址,不过貌似失效了。
TMD 那地址好像时有时无的,抓取代码:
代码语言:javascript复制$song_id = '1051120';
$url = 'http://songtaste.com/play.php?song_id='.$song_id;
$con = file_get_contents($url);
preg_match('|WrtSongLine(.*"(http://.*.mp3)".*);|',$con,$match);
echo $match[1];