?? thiefparsegd.java
字號:
package org.tools.plugin;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.tools.Thief;
public class ThiefParseGD extends ThiefParseBase{
public void doDownload(JFrame frame, Map<String, String> map, JLabel state_label, String saveto) {
// TODO 自動生成方法存根
JOptionPane.showMessageDialog(frame, "對不起,由于無法生成rm文件頭當前版本暫時不支持\nrtsp協議下載,請保存為清單文件\n然后用flashget、影音傳送帶下載。\n 注意:需要另外生成一份有歌曲名稱的詳細列表,\n下載完成用使用GDDJMEND.bat進行歌曲名稱重命名。","下載提示",JOptionPane.INFORMATION_MESSAGE);
}
public Map<String, String> parse(String homeUrl, String musicPrix, String listUrl) {
//以下取得當前URL文檔內容
Thief thief = new Thief();
String content = thief.readURL(listUrl, null);
if (content == null || content.equals(""))
return null;
Map<String, String> map = new HashMap<String, String>();
// 分析內容
Pattern p = Pattern.compile("iframe\\s+src=\\'([^\\']+)\\'\\s+name=\"new\"",Pattern.CASE_INSENSITIVE),
p1 = Pattern.compile("open\\(\"(play.aspx\\?id=\\d+)\",\"play\"\\)",Pattern.CASE_INSENSITIVE),
p2 = Pattern.compile("id=\"ctl00_ContentPlaceHolder1_lbName\"><b>([^>]+)</b></span>",Pattern.CASE_INSENSITIVE),
p3 = Pattern.compile("<param name=\"SRC\"\\s+value=\"([^\"]+)\"",Pattern.CASE_INSENSITIVE)
;
Matcher m = p.matcher(content),m1,m2,m3;
if(!m.find())return map;
//找到真正地址
String realUrl = homeUrl+"/"+m.group(1);
content = thief.readURL(realUrl, null);
m1 = p1.matcher(content);
boolean t = true;
while(m1.find()&&t){
String musicUrl = homeUrl+"/"+m1.group(1),_content;
System.out.println("開始讀取URL:"+musicUrl);
_content = thief.readURL(musicUrl, null);
if(_content == null)continue;
m2 = p2.matcher(_content);
m3 = p3.matcher(_content);
if(m2.find()&&m3.find()){
map.put( m2.group(1),m3.group(1));
System.out.println("分析到 :"+m2.group(1)+" "+m3.group(1));
}
}
return map;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -