Clean code
This commit is contained in:
parent
f9bd3047b5
commit
097e415321
|
|
@ -8,18 +8,18 @@ import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Data {
|
public class Data {
|
||||||
|
|
||||||
|
@SerializedName("video_fragment_list")
|
||||||
|
private List<VideoFragmentList> videoFragmentList;
|
||||||
@SerializedName(value = "video_latest_list", alternate = {"video_list"})
|
@SerializedName(value = "video_latest_list", alternate = {"video_list"})
|
||||||
private List<VideoLatest> videolatestlist;
|
private List<VideoLatest> videolatestlist;
|
||||||
@SerializedName(value = "video", alternate = {"video_soruce"})
|
@SerializedName(value = "video", alternate = {"video_soruce"})
|
||||||
private Video video;
|
private Video video;
|
||||||
@SerializedName("video_fragment_list")
|
|
||||||
private List<VideoFragmentList> videoFragmentList;
|
|
||||||
|
|
||||||
public static Data objectFrom(String str) {
|
public static Data objectFrom(String str) {
|
||||||
JsonObject jsonObject = JsonParser.parseString(str).getAsJsonObject();
|
JsonObject jsonObject = JsonParser.parseString(str).getAsJsonObject();
|
||||||
|
|
@ -27,6 +27,10 @@ public class Data {
|
||||||
return new Data();
|
return new Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VideoFragmentList> getVideoFragmentList() {
|
||||||
|
return videoFragmentList == null ? Collections.emptyList() : videoFragmentList;
|
||||||
|
}
|
||||||
|
|
||||||
public List<VideoLatest> getVideoLatest() {
|
public List<VideoLatest> getVideoLatest() {
|
||||||
return videolatestlist == null ? Collections.emptyList() : videolatestlist;
|
return videolatestlist == null ? Collections.emptyList() : videolatestlist;
|
||||||
}
|
}
|
||||||
|
|
@ -35,8 +39,10 @@ public class Data {
|
||||||
return video == null ? new Video() : video;
|
return video == null ? new Video() : video;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VideoFragmentList> getVideoFragmentList() {
|
public List<Vod> getList() {
|
||||||
return videoFragmentList == null ? Collections.emptyList() : videoFragmentList;
|
List<Vod> list = new ArrayList<>();
|
||||||
|
for (Data.VideoLatest video : getVideoLatest()) list.add(video.vod());
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VideoLatest {
|
public static class VideoLatest {
|
||||||
|
|
@ -153,9 +159,7 @@ public class Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getQualities() {
|
public List<Integer> getQualities() {
|
||||||
if (qualities == null || qualities.isEmpty()) {
|
if (qualities == null || qualities.isEmpty()) return Collections.emptyList();
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
Collections.sort(qualities, Collections.reverseOrder());
|
Collections.sort(qualities, Collections.reverseOrder());
|
||||||
return qualities;
|
return qualities;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,19 +79,17 @@ public class Uvod extends Spider {
|
||||||
if (!extend.isEmpty()) siteUrl = extend;
|
if (!extend.isEmpty()) siteUrl = extend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String encrypt(String data) throws Exception {
|
private String encrypt(String data) throws Exception {
|
||||||
String aesKey = Crypto.randomKey(32);
|
String aesKey = Crypto.randomKey(32);
|
||||||
String aesEncryptedData = Crypto.aesEncrypt(data, aesKey, "abcdefghijklmnop");
|
String aesEncryptedData = Crypto.aesEncrypt(data, aesKey, "abcdefghijklmnop");
|
||||||
String rsaEncryptedKey = Crypto.rsaEncrypt(aesKey, publicKeyPem);
|
String rsaEncryptedKey = Crypto.rsaEncrypt(aesKey, publicKeyPem);
|
||||||
return aesEncryptedData + "." + rsaEncryptedKey;
|
return aesEncryptedData + "." + rsaEncryptedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String decrypt(String encryptedData) throws Exception {
|
private String decrypt(String encryptedData) throws Exception {
|
||||||
encryptedData = encryptedData.replaceAll("\\s", "");
|
encryptedData = encryptedData.replaceAll("\\s", "");
|
||||||
String[] parts = encryptedData.split("\\.");
|
String[] parts = encryptedData.split("\\.");
|
||||||
if (parts.length != 2) {
|
if (parts.length != 2) return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String rsaEncryptedKey = parts[1];
|
String rsaEncryptedKey = parts[1];
|
||||||
String decryptedKey = Crypto.rsaDecrypt(rsaEncryptedKey, privateKeyPem);
|
String decryptedKey = Crypto.rsaDecrypt(rsaEncryptedKey, privateKeyPem);
|
||||||
String aesEncryptedData = parts[0];
|
String aesEncryptedData = parts[0];
|
||||||
|
|
@ -108,12 +106,8 @@ public class Uvod extends Spider {
|
||||||
String encryptData = encrypt(param);
|
String encryptData = encrypt(param);
|
||||||
String content = OkHttp.post(latest, encryptData, getHeader(latest)).getBody();
|
String content = OkHttp.post(latest, encryptData, getHeader(latest)).getBody();
|
||||||
String decryptData = decrypt(content);
|
String decryptData = decrypt(content);
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
Data data = Data.objectFrom(decryptData);
|
Data data = Data.objectFrom(decryptData);
|
||||||
for (Data.VideoLatest video : data.getVideoLatest()) {
|
return Result.string(classes, data.getList());
|
||||||
list.add(video.vod());
|
|
||||||
}
|
|
||||||
return Result.string(classes, list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -122,12 +116,8 @@ public class Uvod extends Spider {
|
||||||
String encryptData = encrypt(param);
|
String encryptData = encrypt(param);
|
||||||
String content = OkHttp.post(list, encryptData, getHeader(list + "|" + tid + "|" + pg)).getBody();
|
String content = OkHttp.post(list, encryptData, getHeader(list + "|" + tid + "|" + pg)).getBody();
|
||||||
String decryptData = decrypt(content);
|
String decryptData = decrypt(content);
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
Data data = Data.objectFrom(decryptData);
|
Data data = Data.objectFrom(decryptData);
|
||||||
for (Data.VideoLatest video : data.getVideoLatest()) {
|
return Result.string(data.getList());
|
||||||
list.add(video.vod());
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -139,14 +129,12 @@ public class Uvod extends Spider {
|
||||||
Data data = Data.objectFrom(decryptData);
|
Data data = Data.objectFrom(decryptData);
|
||||||
StringBuilder vod_play_url = new StringBuilder();
|
StringBuilder vod_play_url = new StringBuilder();
|
||||||
List<Data.VideoFragmentList> videoFragmentList = data.getVideoFragmentList();
|
List<Data.VideoFragmentList> videoFragmentList = data.getVideoFragmentList();
|
||||||
List<Integer> acceptQuality = new ArrayList<>();
|
|
||||||
for (int j = 0; j < videoFragmentList.size(); j++) {
|
for (int j = 0; j < videoFragmentList.size(); j++) {
|
||||||
Data.VideoFragmentList videolist = videoFragmentList.get(j);
|
Data.VideoFragmentList videoList = videoFragmentList.get(j);
|
||||||
String name = videolist.getSymbol();
|
String name = videoList.getSymbol();
|
||||||
String nid = videolist.getId();
|
String nid = videoList.getId();
|
||||||
List<Integer> Qualities = videolist.getQualities();
|
List<Integer> Qualities = videoList.getQualities();
|
||||||
nid = ids.get(0) + "|" + nid + "|" + Qualities;
|
nid = ids.get(0) + "|" + nid + "|" + Qualities;
|
||||||
|
|
||||||
vod_play_url.append(name).append("$").append(nid);
|
vod_play_url.append(name).append("$").append(nid);
|
||||||
boolean notLastEpisode = j < videoFragmentList.size() - 1;
|
boolean notLastEpisode = j < videoFragmentList.size() - 1;
|
||||||
vod_play_url.append(notLastEpisode ? "#" : "$$$");
|
vod_play_url.append(notLastEpisode ? "#" : "$$$");
|
||||||
|
|
@ -172,12 +160,8 @@ public class Uvod extends Spider {
|
||||||
String encryptData = encrypt(param);
|
String encryptData = encrypt(param);
|
||||||
String content = OkHttp.post(list, encryptData, getHeader(list + "|" + key)).getBody();
|
String content = OkHttp.post(list, encryptData, getHeader(list + "|" + key)).getBody();
|
||||||
String decryptData = decrypt(content);
|
String decryptData = decrypt(content);
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
Data data = Data.objectFrom(decryptData);
|
Data data = Data.objectFrom(decryptData);
|
||||||
for (Data.VideoLatest video : data.getVideoLatest()) {
|
return Result.string(data.getList());
|
||||||
list.add(video.vod());
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -185,31 +169,20 @@ public class Uvod extends Spider {
|
||||||
String[] item = id.split("\\|");
|
String[] item = id.split("\\|");
|
||||||
String tid = item[0];
|
String tid = item[0];
|
||||||
String nid = item[1];
|
String nid = item[1];
|
||||||
String[] quality = item[2].replaceAll("[\\[\\]]", "").split(",");
|
String[] quality = item[2].replaceAll("[\\[\\]]", "").replace(" ", "").split(",");
|
||||||
List<String> url = new ArrayList<>();
|
List<String> url = new ArrayList<>();
|
||||||
for (int i = 0; i < quality.length; i++) {
|
for (String s : quality) {
|
||||||
String qualityValue = quality[i].trim();
|
if (s.equals("4")) url.add("1080p");
|
||||||
switch (qualityValue) {
|
else if (s.equals("3")) url.add("720p");
|
||||||
case "4":
|
else if (s.equals("2")) url.add("480p");
|
||||||
url.add("1080p");
|
else if (s.equals("1")) url.add("360p");
|
||||||
break;
|
else url.add(s.trim());
|
||||||
case "3":
|
String param = String.format("{\"video_id\":\"%s\",\"video_fragment_id\":%s,\"quality\":%s,\"seek\":null}", tid, nid, s.trim());
|
||||||
url.add("720p");
|
|
||||||
break;
|
|
||||||
case "1":
|
|
||||||
url.add("360p");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
url.add(qualityValue);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String param = String.format("{\"video_id\":\"%s\",\"video_fragment_id\":%s,\"quality\":%s,\"seek\":null}", tid, nid, quality[i].trim());
|
|
||||||
String encryptData = encrypt(param);
|
String encryptData = encrypt(param);
|
||||||
String content = OkHttp.post(play, encryptData, getHeader(play + "|" + tid + "|" + nid + "|" + quality[i].trim())).getBody();
|
String content = OkHttp.post(play, encryptData, getHeader(play + "|" + tid + "|" + nid + "|" + s.trim())).getBody();
|
||||||
String decryptData = decrypt(content);
|
String decryptData = decrypt(content);
|
||||||
Data data = Data.objectFrom(decryptData);
|
Data data = Data.objectFrom(decryptData);
|
||||||
Data.Video video = data.getVideo();
|
url.add(data.getVideo().getUrl());
|
||||||
url.add(video.getUrl());
|
|
||||||
}
|
}
|
||||||
return Result.get().url(url).header(playHeader()).string();
|
return Result.get().url(url).header(playHeader()).string();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
f07fdfd86e4a8eb8198f9b2539c015d1
|
d6377af2846bf4ae821a802907d89236
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue