}else{
//获得mp3的真实地址
analyBaiduMusic();
}
}
loadBaiduMusic();
}
}
//----分析下载内容生成歌曲地址列表----
function analyBaiduList(){
var strHTML=b2s(xmlHttp.responseBody);
var iStart=strHTML.search(/<body/i);
var iEnd=strHTML.toLowerCase().indexOf("<\/script",iStart+5);
strHTML=strHTML.substring(iStart,iEnd);
var fff=document.createElement("Iframe");
fff.id="tempFrame";
fff.style.display="none";
document.body.insertBefore(fff);
theWin=eval("tempFrame");
theWin.document.open();
theWin.document.clear();
theWin.document.write(strHTML);
theWin.document.close();
for(var i=0;i<theWin.document.links.length;i++){
if(theWin.document.links[i].href.match(/mp3.baidu.com\/m\?tn=baidump3\&ct=/i)&&theWin.document.links[i].parentNode.firstChild==theWin.document.links[i]){
//将url存入taskURLs,歌曲名称存入taskNames
taskURLs[taskURLs.length]=theWin.document.links[i].href.replace(/lm=-1/,"lm=0");
taskNames[taskNames.length]=theWin.document.links[i].innerText;
}
}
fff.outerHTML="";
}
//----获得mp3的真实地址,添加到music list-----
function analyBaiduMusic(){
var strHTML=b2s(xmlHttp.responseBody);
var strTxt=taskNames[currentTask];
//匹配URL的正则
var aryURL=strHTML.match(/ http:\/\/[^ ]+ /gi);
if(!aryURL){return(false);}
var theC=document.createElement("DIV");
theC.className="item";
musicListContent.insertBefore(theC);
//获取10个地址以免链接失效
for(var i=0;i<10&&i<aryURL.length;i++){
//每个item的容器
var theD=document.createElement("DIV");
theD.onmouseover=musicList_mouseover;
theD.onmouseout=musicList_mouseout;
//link元素
var theLink=document.createElement("A");
var strURL=aryURL[i].substring(2,aryURL[i].length-2);
theLink.href=strURL;
theLink.title=strURL;
theLink.innerText=(currentTask+1)+"."+strTxt;
if(i>0){theLink.innerText+="."+(i+1);}
theLink.onclick=musicList_item_click;
theD.insertBefore(theLink);
//添加到列表按钮
theButton=document.createElement("Span");
theButton.className="add2ListBtn";
theButton.innerText="1";