Cập nhật 27/07/2007 : lấy link download theoyeucau.com tại :
http://www.guru.net.vn/media.aspxtheoyeucau.com là một trang nghe nhạc, có các file nhạc đã được che dấu.
Mục tiêu : tìm ra địa chỉ thực của file nhạc
Bài viết hướng dẫn trên cơ sở để lập trình auto lấy link.
Ví dụ bài :
http://www.theoyeucau.com/Home/Onair/Cam_Xuc_Cuoc_Song/2007/04/29/Su_Co_Don/01/Daniel_Powter_Bad_Day/
Khi vào trang đó để nghe 1 bài hát bạn sẽ thấy 1 cái flash player bạn download nó về.
http://www.theoyeucau.com/HTML/data/flash/Player.swfBạn dùng 1 phần mềm decompliler cái này. Vì bản chất flash chạy action script giống java script nên các hàm của nó chạy ở phía client.
File dữ liệu trả về cho player :
http://www.theoyeucau.com/Home/Onair/Cam_Xuc_Cuoc_Song/2007/04/29/Su_Co_Don/01/Daniel_Powter_Bad_Day/XML/?refer=/Home/Onair/Cam_Xuc_Cuoc_Song/2007/04/29/Su_Co_Don/01/Daniel_Powter_Bad_Day/XML/
Các thông tin cần chú ý :
<host>
http://music.theoyeucau.com/Music/Programs/CamXucCuocSong/2007/2007-04-29
</host>
<ext>718871923175</ext>
−
<song>
<id>948</id>
<title>Daniel Powter - Bad Day</title>
−
<file>
6072507220798072407140806071107950762076311840727118309161202133812891248131611861032134814241392124413781187089412081237118909141208144
</file>
Url File đã bị mã hóa.
Sau khi decompliler bạn tìm thấy các dòng sau là đáng chú ý :
_l3 = _root.host + "/" + e(_l5, _l3) + "." + _root.ext + "?refer=" + _l3;
_13 chính là URL mà player lấy để chạy.
if (xml.lastChild.childNodes[list[index]].childNodes[i].nodeName == "file")
{
_l3 = xml.lastChild.childNodes[list[index]].childNodes[i].firstChild.nodeValue;
} // end if
if (xml.lastChild.childNodes[list[index]].childNodes[i].nodeName == "title")
{
_l5 = xml.lastChild.childNodes[list[index]].childNodes[i].firstChild.nodeValue;
} // end if
Cần xác định
e(_l5, _l3),_root.extHàm e :
function e(title, file)
{
var _l4 = "";
var _l1 = "";
var _l2 = 0;
for (i = 0; i < Math.ceil(file.length / 4); i++)
{
_l1 = file.substr(i * 4, 4);
_l1 = _l1.substr(1, 3);
if (_l1.substr(0, 1) == "0")
{
_l1 = _l1.substr(1, 2);
} // end if
_l2 = parseInt(_l1) - title.length;
_l4 = _l4 + chr(_l2);
} // end of for
return(_l4);
} // End of the function
công thức tính _root.ext = e(host, ext);
Tôi dùng C# để viết, cần chuyển hàm e sang C# và viết thêm 1 chút.
public string XmlReaderTheoyeucau(string Xml_url)
{
string host="";
string ext="";
int id =0;
string title ="";
string file ="";
string artist ="";
string name ="";
string content ="";
string url="";
url="";
try
{
WebRequest myRequest = WebRequest.Create(Xml_url);
WebResponse myResponse = myRequest.GetResponse();
//Stream rssStream = myResponse.GetResponseStream();
StreamReader streamReader =new StreamReader(myResponse.GetResponseStream(),Encoding.UTF8);
string temp =streamReader.ReadToEnd();
temp = temp.Replace("&"," ");
XmlDocument rssDoc = new XmlDocument();
//rssDoc.Load(rssStream);
rssDoc.LoadXml(temp);
XmlNodeList rssItems = rssDoc.SelectNodes("doc/song");
XmlNode node=null;
node =rssDoc.SelectSingleNode("doc/host");
host =node.InnerText;
host = host.Replace("\r\n","");
node =rssDoc.SelectSingleNode("doc/ext");
ext =node.InnerText;
for (int i = 0; i < rssItems.Count; i++)
{
XmlNode rssDetail;
rssDetail = rssItems.Item(i).SelectSingleNode("id");
if (rssDetail != null)
{
id = Convert.ToInt32(rssDetail.InnerText.Replace("\r\n",""));
}
else
{
id=0;
}
rssDetail = rssItems.Item(i).SelectSingleNode("title");
if (rssDetail != null)
{
title = rssDetail.InnerText.Replace("\r\n","");
}
else
{
title = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("file");
if (rssDetail != null)
{
file = rssDetail.InnerText.Replace("\r\n","");
}
else
{
file = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("artist");
if (rssDetail != null)
{
artist = rssDetail.InnerText.Replace("\r\n","");
}
else
{
artist = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("name");
if (rssDetail != null)
{
name = rssDetail.InnerText.Replace("\r\n","");
}
else
{
name = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("content");
if (rssDetail != null)
{
content = rssDetail.InnerText;
}
else
{
content = "";
}
}
url = host + "/" + EncryptThepyeucau(title, file) + "." + EncryptThepyeucau(host,ext) + "?refer=" + file;
}
catch (Exception ex)
{
url = ex.Message;
}
return url;
}
public string EncryptThepyeucau(string title,string file)
{
string _l4 = "";
string _l1 = "";
int _l2 = 0;
for (int i = 0; i < Math.Ceiling(file.Length / 4); i++)
{
_l1 = file.Substring(i * 4, 4);
_l1 = _l1.Substring(1, 3);
if (_l1.Substring(0, 1) == "0")
{
_l1 = _l1.Substring(1, 2);
} // end if
_l2 = Convert.ToInt32(_l1) - title.Length;
_l4 = _l4 + Convert.ToChar(_l2);
} // end of for
return(_l4);
}
Kết quả cuối cùng :
Url file nhạc :
http://music.theoyeucau.com/Music/Programs/CamXucCuocSong/2007/2007-04-29/1181090855_1_Daniel_Powter_Bad_Day.swf?refer=6072507220798072407140806071107950762076311840727118309161202133812891248131611861032134814241392124413781187089412081237118909141208144
Bạn download về và đổi thành .mp3 là nghe tốt.
Hôm nào sẽ viết tiếp thành auto tool