-
Notifications
You must be signed in to change notification settings - Fork 0
/
getalbums.php
50 lines (44 loc) · 2.54 KB
/
getalbums.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$url = "http://www.google.cn/music/artist?id=".$_POST['id'];
$pagedata = file_get_contents($url);
//
//
$reg = "/player_iframe%3Fid%3D(\w+).*?\">([^<].*?)</";
preg_match_all($reg,$pagedata,$hotsongs,PREG_SET_ORDER);
$dom = new DOMDocument('1.0','utf-8');
$playlistNode = $dom->CreateElement("playlist");
$dom->appendChild($playlistNode);
$listnameNode = $dom->CreateElement("listname");
$listnameNode->appendChild($dom->CreateTextNode("temp"));
$playlistNode->appendChild($listnameNode);
$songListNode = $dom->CreateElement("songList");
$playlistNode->appendChild($songListNode);
foreach($hotsongs as $song){
$name = html_entity_decode($song[2],ENT_COMPAT,"utf-8");
$songNode = $dom->CreateElement("song");
$songid = $dom->CreateElement("id");
$songname = $dom->CreateElement("name");
$songid->appendChild($dom->CreateTextNode($song[1]));
$songname->appendChild($dom->CreateTextNode($name));
$songNode->appendChild($songid);
$songNode->appendChild($songname);
$songListNode->appendChild($songNode);
}
$dom->save("ownlist/temp.pli");
//
//
preg_match("/(?<=width=\"100%\" align=\"left\">)[^<]+/",$pagedata,$artistname);
preg_match_all("/left\"><a href=\"\/music\/url\?q=%2Fmusic%2Falbum%3Fid%3D(\w+).*?《([^》]*)/u",$pagedata,$results,PREG_SET_ORDER);
echo "<span style='font-weight:bold;background-color:#999;color:#555;padding:0px 10px 0px 10px;margin-left:2px;'>{$artistname[0]}的专辑列表</span><table>";
echo "<tr><td bgcolor='#cccccc'><a href='ownlist/temp.pli' style='display:block' onclick='a_onclick(this);return false;'>热门歌曲_{$artistname[0]}</a></td><td><span style='font-size:12px;background-color:#666;color:#bbb;float:right;display:block;padding:2px;cursor:pointer;width:24px;' onclick='loadsonglist(\"playlist=temp.pli\",\"热门歌曲_{$artistname[0]}\",{\"pageY\":event.pageY?event.pageY:event.y,\"clientX\":event.clientX});'>详情</span></td></tr>";
$i = 0;
foreach ($results as $result){
$color = ($i%2)?"#cccccc":"#bbbbbb";
$id = $result[1];
$name = $result[2];
$name_special = htmlspecialchars($name);
echo "<tr><td bgcolor='$color'><a href='http://www.google.cn/music/album?id=$id&output=xml' style='display:block' onclick='a_onclick(this);return false;'>$name</a></td><td><span style='font-size:12px;background-color:#666;color:#bbb;float:right;display:block;padding:2px;cursor:pointer;width:24px;' onclick='loadsonglist(\"playlist=$id&cat=ablum\",\"$name_special\",{\"pageY\":event.pageY?event.pageY:event.y,\"clientX\":event.clientX});'>详情</span></td></tr>";
$i++;
}
echo "</table>";
?>