愛奇藝視頻解析(Java代碼)(16.5.30更新)

注:此代碼僅供學習交流 不做商務用途

public class CrackIQiyi extends CrackBase {
private final static Logger logger = LoggerFactory
.getLogger(CrackIQiyi.class);


String tvid;


public CrackIQiyi(String url) {
super(url);
}




@Override
public String parseVideoUrl() {
String ret = "";
String webUrl =url;
if (StringUtils.isEmpty(webUrl))
return ret;
try {
String str1 = Utils.execute("", webUrl);
if (StringUtils.isEmpty(str1)) {
return ret;
}
String str4 = null;
String str3 = null;
String str2 = null;
Matcher localMatcher1 = Pattern.compile("albumId:[\\s]*?([0-9]+)")
.matcher(str1);
Matcher localMatcher2 = Pattern.compile("tvId:[\\s]*?([0-9]+)")
.matcher(str1);
Matcher localMatcher3 = Pattern.compile("cid:[\\s]*?([0-9]+)")
.matcher(str1);
if ((localMatcher1 != null) && (localMatcher1.find())
&& (localMatcher1.groupCount() > 0)
&& (localMatcher2 != null) && (localMatcher2.find())
&& (localMatcher2.groupCount() > 0)
&& (localMatcher3 != null) && (localMatcher3.find())
&& (localMatcher3.groupCount() > 0)) {
str4 = localMatcher1.group(1);
str3 = localMatcher2.group(1);
str2 = localMatcher3.group(1);
}
Matcher localMatcher4 = Pattern.compile(
"data-player-albumid=\"([0-9]+)\"").matcher(str1);
Matcher localMatcher5 = Pattern.compile(
"data-player-tvid=\"([0-9]+)\"").matcher(str1);
Matcher localMatcher6 = Pattern.compile(
"data-errorqiyu-cid=\"([0-9]+)\"").matcher(str1);
if ((localMatcher4 != null) && (localMatcher4.find())
&& (localMatcher4.groupCount() > 0)
&& (localMatcher5 != null) && (localMatcher5.find())
&& (localMatcher5.groupCount() > 0)
&& (localMatcher6 != null) && (localMatcher6.find())
&& (localMatcher6.groupCount() > 0)) {
str4 = localMatcher4.group(1);
str3 = localMatcher5.group(1);
str2 = localMatcher6.group(1);
}


String videoid = null;
Matcher localMatcher8 = Pattern.compile(
"data-player-videoid=\"([^\"]+)\"").matcher(str1);
if ((localMatcher8 != null) && (localMatcher8.find())
&& (localMatcher8.groupCount() > 0))
videoid = localMatcher8.group(1);
int time = (int) (Utils.getNetime() / 1000L);
Object[] arrayOfObject = new Object[5];
tvid = String.valueOf(str3);
arrayOfObject[0] = String.valueOf(str3);
arrayOfObject[1] = String.valueOf(videoid);
arrayOfObject[2] = time;
arrayOfObject[3] = Utils.StringToLowercaseMD5(time
+ "d5fb4bd9d50c4be6948c97edd7254b0e" + str3);
arrayOfObject[4] = "20140213141851016xMqipWjr10182";
String ress = String
.format("http://cache.m.iqiyi.com/tmts/%s/%s/?t=%s&sc=%s&src=76f90cbd92f94a2e925d83e8ccd22cb7&uid=%s",
arrayOfObject);


String html = Utils.GetSource(ress);
JSONObject localJSONObject1 = new JSONObject(html);
JSONObject localJSONObject2 = localJSONObject1
.optJSONObject("data");
if (localJSONObject2 != null) {
String str_4 = localJSONObject2.optString("vd").trim();
String str5 = localJSONObject2.optString("m3u");
String str6 = localJSONObject2.optString("m3utx")
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
if (type(str_4)) {
int j = str5.indexOf("?");
if (j > 0) {
stand = str5.substring(0, j)
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
} else {
stand = str6;
}


}
JSONArray localJSONArray = localJSONObject2
.getJSONArray("vidl");
for (int in = 0; in < localJSONArray.length(); in++) {
JSONObject localJSONObject3 = localJSONArray
.getJSONObject(in);
if (localJSONObject3 != null) {
String str7 = localJSONObject3.optString("vd").trim();
if (!str7.equals(str_4)) {
String str8 = localJSONObject3.optString("vid");
getMoreSource(str8);
}
}
}
System.out.println(stand);
System.out.println(high);
System.out.println(sup);
return SUCCESS;
}
} catch (Exception ex) {
logger.error(ex.toString(), ex);
}
return FAIL;
}


public static boolean type(String paramString) {
return (paramString.equals("1")) || (paramString.equals("2"))
|| (paramString.equals("4")) || (paramString.equals("5"));
}


public void getMoreSource(String videoid) {
int time = (int) (Utils.getNetime() / 1000L);
Object[] arrayOfObject = new Object[5];
arrayOfObject[0] = String.valueOf(tvid);
arrayOfObject[1] = String.valueOf(videoid);
arrayOfObject[2] = time;
arrayOfObject[3] = Utils.StringToLowercaseMD5(time
+ "d5fb4bd9d50c4be6948c97edd7254b0e" + tvid);
arrayOfObject[4] = "20140213141851016xMqipWjr10182";
String ress = String
.format("http://cache.m.iqiyi.com/tmts/%s/%s/?t=%s&sc=%s&src=76f90cbd92f94a2e925d83e8ccd22cb7&uid=%s",
arrayOfObject);


String html = Utils.GetSource(ress);
JSONObject localJSONObject1;
try {
localJSONObject1 = new JSONObject(html);


JSONObject localJSONObject2 = localJSONObject1
.optJSONObject("data");
if (localJSONObject2 != null) {
String str4 = localJSONObject2.optString("vd").trim();
String str5 = localJSONObject2.optString("m3u");
String str6 = localJSONObject2.optString("m3utx")
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
if (type(str4)) {
int j = str5.indexOf("?");


if (str4.equals("1")) {
if (j > 0) {
stand = str5.substring(0, j)
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
} else {
stand = str6;
}
} else if (str4.equals("2")) {
if (j > 0) {
high = str5.substring(0, j)
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
} else {
high = str6;
}
} else if (str4.equals("4")) {
if (j > 0) {
sup = str5.substring(0, j)
+ "?src=76f90cbd92f94a2e925d83e8ccd22cb7";
} else {
sup = str6;
}
}


}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}


注:時間問題 不做詳細解析 如有需求 請留言詢問  代碼7-10天會上傳至github  屆時會提供鏈接




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章