Clean code

This commit is contained in:
FongMi 2023-08-30 23:42:10 +08:00
parent 8f8f0fcba1
commit 006a785b1c
4 changed files with 24 additions and 116 deletions

View File

@ -1,85 +0,0 @@
package com.github.catvod.bean.yiso;
import com.github.catvod.bean.Vod;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Item {
@SerializedName("data")
private DataDTO data;
public static Item objectFrom(String str) {
try {
return new Gson().fromJson(str, Item.class);
} catch (Exception e) {
e.printStackTrace();
return new Item();
}
}
public DataDTO getData() {
return data == null ? new DataDTO() : data;
}
public static class DataDTO {
@SerializedName("list")
private List<ListDTO> list;
public List<Vod> getList(String key) {
List<Vod> items = new ArrayList<>();
list = list == null ? Collections.emptyList() : list;
for (ListDTO item : list) if (item.getName().contains(key)) items.add(item.getVod());
return items;
}
public static class ListDTO {
@SerializedName("url")
private String url;
@SerializedName("gmtCreate")
private String gmtCreate;
@SerializedName("fileInfos")
private List<FileInfoDTO> fileInfos;
public String getUrl() {
return url;
}
public String getGmtCreate() {
return gmtCreate;
}
public List<FileInfoDTO> getFileInfos() {
return fileInfos;
}
public String getName() {
return getFileInfos().get(0).getFileName();
}
public Vod getVod() {
String id = getUrl();
String name = getName();
String remark = getGmtCreate();
String pic = "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000";
return new Vod(id, name, pic, remark);
}
public static class FileInfoDTO {
@SerializedName("fileName")
private String fileName;
public String getFileName() {
return fileName;
}
}
}
}
}

View File

@ -1,11 +1,9 @@
package com.github.catvod.spider;
import android.content.Context;
import android.util.Base64;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.net.OkHttp;
import org.json.JSONArray;
@ -20,47 +18,42 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class YiSo extends Ali {
@Override
public void init(Context context, String extend) {
super.init(context, extend);
private HashMap<String, String> getHeaders() {
HashMap<String, String> headers = new HashMap<>();
headers.put("User-Agent", "Mozilla/5.0 (Linux; Android 12; V2049A Build/SP1A.210812.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36");
headers.put("Referer", "https://yiso.fun/");
headers.put("Cookie", "satoken=2854cb58-3884-473b-84c4-34161f67a409");
return headers;
}
@Override
public String searchContent(String key, boolean quick) throws Exception {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("User-Agent", "Mozilla/5.0 (Linux; Android 12; V2049A Build/SP1A.210812.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36");
hashMap.put("Referer", "https://yiso.fun/");
hashMap.put("Cookie", "satoken=2854cb58-3884-473b-84c4-34161f67a409");
String poststr = OkHttp.string("https://yiso.fun/api/search?name=" + URLEncoder.encode(key) + "&pageNo=1&from=ali", hashMap);
SpiderDebug.log(poststr);
JSONArray jsonArray = new JSONObject(poststr).getJSONObject("data").getJSONArray("list");
ArrayList<Vod> arrayList = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
String json = OkHttp.string("https://yiso.fun/api/search?name=" + URLEncoder.encode(key) + "&pageNo=1&from=ali", getHeaders());
JSONArray array = new JSONObject(json).getJSONObject("data").getJSONArray("list");
ArrayList<Vod> list = new ArrayList<>();
for (int i = 0; i < array.length(); i++) {
Vod vod = new Vod();
String string = jsonArray.getJSONObject(i).getJSONArray("fileInfos").getJSONObject(0).getString("fileName");
String string2 = jsonArray.getJSONObject(i).getString("gmtCreate");
vod.setVodId(decrypt(jsonArray.getJSONObject(i).getString("url")));
vod.setVodName(string);
String name = array.getJSONObject(i).getJSONArray("fileInfos").getJSONObject(0).getString("fileName");
String remark = array.getJSONObject(i).getString("gmtCreate");
vod.setVodId(decrypt(array.getJSONObject(i).getString("url")));
vod.setVodName(name);
vod.setVodRemarks(remark);
vod.setVodPic("https://inews.gtimg.com/newsapp_bt/0/13263837859/1000");
vod.setVodRemarks(string2);
arrayList.add(vod);
list.add(vod);
}
return Result.string(arrayList);
// return ("55555555555555");
return Result.string(list);
}
public static String decrypt(String str) {
public String decrypt(String str) {
try {
SecretKeySpec secretKeySpec = new SecretKeySpec("4OToScUFOaeVTrHE".getBytes("UTF-8"), "AES");
IvParameterSpec ivParameterSpec = new IvParameterSpec("9CLGao1vHKqm17Oz".getBytes("UTF-8"));
SecretKeySpec key = new SecretKeySpec("4OToScUFOaeVTrHE".getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec("9CLGao1vHKqm17Oz".getBytes("UTF-8"));
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(2, secretKeySpec, ivParameterSpec);
cipher.init(Cipher.DECRYPT_MODE, key, iv);
return new String(cipher.doFinal(Base64.decode(str.getBytes(), 0)), "UTF-8");
} catch (Exception unused) {
} catch (Exception e) {
return "";
}
}
}

Binary file not shown.

View File

@ -1 +1 @@
a0fb5dc6e2d2199a6663c3d5cee4bedb
0cd8dd32e89511058fd8e6bceb586a28