Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
7e0979a7e9
|
|
@ -27,7 +27,7 @@ public class Result {
|
|||
@SerializedName("url")
|
||||
private String url;
|
||||
@SerializedName("sub")
|
||||
private String sub;
|
||||
private List<Sub> sub;
|
||||
@SerializedName("parse")
|
||||
private int parse;
|
||||
@SerializedName("jx")
|
||||
|
|
@ -129,7 +129,7 @@ public class Result {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Result sub(String sub) {
|
||||
public Result sub(List<Sub> sub) {
|
||||
this.sub = sub;
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.github.catvod.bean;
|
||||
|
||||
import com.github.catvod.utils.Trans;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Sub {
|
||||
|
||||
@SerializedName("url")
|
||||
private String url;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("lang")
|
||||
private String lang;
|
||||
@SerializedName("format")
|
||||
private String format;
|
||||
|
||||
public static Sub create() {
|
||||
return new Sub();
|
||||
}
|
||||
|
||||
public Sub name(String name) {
|
||||
this.name = Trans.get(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sub url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sub lang(String lang) {
|
||||
this.lang = lang;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sub format(String format) {
|
||||
this.format = format;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sub ext(String ext) {
|
||||
switch (ext) {
|
||||
case "vtt":
|
||||
return format("text/vtt");
|
||||
case "ass":
|
||||
case "ssa":
|
||||
return format("text/x-ssa");
|
||||
default:
|
||||
return format("application/x-subrip");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.github.catvod.bean.ali;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class Auth {
|
||||
|
||||
private String refreshToken;
|
||||
private String accessToken;
|
||||
private long expiresTime;
|
||||
private ImageView view;
|
||||
|
||||
public Auth(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
public String getRefreshToken() {
|
||||
return TextUtils.isEmpty(refreshToken) ? "" : refreshToken;
|
||||
}
|
||||
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return TextUtils.isEmpty(accessToken) ? "" : accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public long getExpiresTime() {
|
||||
return expiresTime;
|
||||
}
|
||||
|
||||
public void setExpiresTime(long expiresTime) {
|
||||
this.expiresTime = expiresTime;
|
||||
}
|
||||
|
||||
public ImageView getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setView(ImageView view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public boolean needRefresh() {
|
||||
return System.currentTimeMillis() > getExpiresTime();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getRefreshToken().isEmpty() || getAccessToken().isEmpty();
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
setRefreshToken("");
|
||||
setAccessToken("");
|
||||
setExpiresTime(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -31,10 +31,10 @@ public class Item {
|
|||
@SerializedName("list")
|
||||
private List<ListDTO> list;
|
||||
|
||||
public List<Vod> getList() {
|
||||
public List<Vod> getList(String key) {
|
||||
List<Vod> items = new ArrayList<>();
|
||||
list = list == null ? Collections.emptyList() : list;
|
||||
for (ListDTO item : list) items.add(item.getVod());
|
||||
for (ListDTO item : list) if (item.getName().contains(key)) items.add(item.getVod());
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
@ -59,9 +59,13 @@ public class Item {
|
|||
return fileInfos;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getFileInfos().get(0).getFileName();
|
||||
}
|
||||
|
||||
public Vod getVod() {
|
||||
String id = getUrl();
|
||||
String name = getFileInfos().get(0).getFileName();
|
||||
String name = getName();
|
||||
String remark = getGmtCreate();
|
||||
String pic = "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000";
|
||||
return new Vod(id, name, pic, remark);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.text.TextUtils;
|
|||
import com.github.catvod.bean.Class;
|
||||
import com.github.catvod.bean.Filter;
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Sub;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.bean.alist.Drive;
|
||||
import com.github.catvod.bean.alist.Item;
|
||||
|
|
@ -165,8 +166,7 @@ public class AList extends Spider {
|
|||
String response = OkHttp.postJson(drive.searchApi(), drive.params(keyword));
|
||||
List<Item> items = Item.arrayFrom(getSearchJson(drive.isNew(), response));
|
||||
for (Item item : items) if (!item.ignore(drive.isNew())) list.add(item.getVod(drive));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception ignored) {
|
||||
} finally {
|
||||
cd.countDown();
|
||||
}
|
||||
|
|
@ -198,17 +198,20 @@ public class AList extends Spider {
|
|||
|
||||
private String findSubs(String path, List<Item> items) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Item item : items) if (Misc.isSub(item.getExt())) sb.append("~~~").append(Trans.get(item.getName())).append("@@@").append(Misc.getSubMimeType(item.getExt())).append("@@@").append(item.getVodId(path));
|
||||
for (Item item : items) if (Misc.isSub(item.getExt())) sb.append("~~~").append(item.getName()).append("@@@").append(item.getExt()).append("@@@").append(item.getVodId(path));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getSub(String[] ids) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
private List<Sub> getSub(String[] ids) {
|
||||
List<Sub> sub = new ArrayList<>();
|
||||
for (String text : ids) {
|
||||
if (!text.contains("@@@")) continue;
|
||||
String[] arr = text.split("@@@");
|
||||
sb.append(arr[0]).append("#").append(arr[1]).append("#").append(getDetail(arr[2]).getUrl()).append("$$$");
|
||||
String[] split = text.split("@@@");
|
||||
String name = split[0];
|
||||
String ext = split[1];
|
||||
String url = getDetail(split[2]).getUrl();
|
||||
sub.add(Sub.create().name(name).ext(ext).url(url));
|
||||
}
|
||||
return Misc.substring(sb.toString(), 3);
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,9 @@ import android.widget.FrameLayout;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Sub;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.bean.ali.Auth;
|
||||
import com.github.catvod.bean.ali.Data;
|
||||
import com.github.catvod.bean.ali.Item;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
|
|
@ -42,27 +44,26 @@ public class Ali {
|
|||
|
||||
private final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
||||
private ScheduledExecutorService service;
|
||||
private static String authorization;
|
||||
private String refreshToken;
|
||||
private long expiresTime;
|
||||
private ImageView view;
|
||||
private Auth auth;
|
||||
|
||||
public Ali(String token) {
|
||||
public Ali token(String token) {
|
||||
if (auth != null && auth.getRefreshToken().length() > 0) return this;
|
||||
if (TextUtils.isEmpty(token)) Init.show("尚未設定 Token");
|
||||
if (token.startsWith("http")) token = OkHttp.string(token);
|
||||
refreshToken = Prefers.getString("token", token);
|
||||
auth = new Auth(Prefers.getString("token", token));
|
||||
return this;
|
||||
}
|
||||
|
||||
private static HashMap<String, String> getHeaders() {
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("Referer", "https://www.aliyundrive.com/");
|
||||
return headers;
|
||||
}
|
||||
|
||||
private static HashMap<String, String> getHeaders(String shareToken) {
|
||||
private HashMap<String, String> getHeaders(String shareToken) {
|
||||
HashMap<String, String> headers = getHeaders();
|
||||
if (authorization != null) headers.put("authorization", authorization);
|
||||
headers.put("authorization", auth.getAccessToken());
|
||||
headers.put("x-share-token", shareToken);
|
||||
return headers;
|
||||
}
|
||||
|
|
@ -72,9 +73,17 @@ public class Ali {
|
|||
return OkHttp.postJson(url, body.toString(), getHeaders());
|
||||
}
|
||||
|
||||
private static String post(String url, JSONObject body, String shareToken) {
|
||||
private String post(String url, JSONObject body, String shareToken) {
|
||||
url = url.startsWith("https") ? url : "https://api.aliyundrive.com/" + url;
|
||||
return OkHttp.postJson(url, body.toString(), getHeaders(shareToken));
|
||||
String result = OkHttp.postJson(url, body.toString(), getHeaders(shareToken));
|
||||
if (check401(result)) return post(url, body, shareToken);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean check401(String result) {
|
||||
if (!result.contains("AccessTokenInvalid")) return false;
|
||||
refreshAccessToken();
|
||||
return true;
|
||||
}
|
||||
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
|
|
@ -85,14 +94,13 @@ public class Ali {
|
|||
}
|
||||
|
||||
public String playerContent(String flag, String id) {
|
||||
if (id.equals("无数据")) return "";
|
||||
if (id.equals("Empty")) return "";
|
||||
String[] ids = id.split("\\+");
|
||||
String shareId = ids[0];
|
||||
String shareToken = ids[1];
|
||||
String fileId = ids[2];
|
||||
String sub = getSub(shareId, shareToken, ids);
|
||||
if (System.currentTimeMillis() > expiresTime) refreshAccessToken();
|
||||
while (TextUtils.isEmpty(authorization)) SystemClock.sleep(250);
|
||||
List<Sub> sub = getSub(shareId, shareToken, ids);
|
||||
if (auth.needRefresh()) refreshAccessToken();
|
||||
if (flag.equals("原畫")) {
|
||||
return Result.get().url(getDownloadUrl(shareId, shareToken, fileId)).sub(sub).header(getHeaders()).string();
|
||||
} else {
|
||||
|
|
@ -114,7 +122,7 @@ public class Ali {
|
|||
List<String> playUrls = new ArrayList<>();
|
||||
List<Item> files = new ArrayList<>(fileMap.keySet());
|
||||
for (Item file : files) playUrls.add(Trans.get(file.getDisplayName()) + "$" + fileMap.get(file) + findSubs(file.getName(), subMap));
|
||||
if (playUrls.isEmpty()) playUrls.add("无数据$无数据");
|
||||
if (playUrls.isEmpty()) playUrls.add("Empty$Empty");
|
||||
List<String> sourceUrls = new ArrayList<>();
|
||||
sourceUrls.add(TextUtils.join("#", playUrls));
|
||||
sourceUrls.add(TextUtils.join("#", playUrls));
|
||||
|
|
@ -151,7 +159,7 @@ public class Ali {
|
|||
} else if (Misc.isSub(file.getExt())) {
|
||||
String key = file.removeExt();
|
||||
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());
|
||||
subMap.get(key).add(key + "@@@" + file.getFileId() + "@@@" + file.getExt());
|
||||
subMap.get(key).add(key + "@@@" + file.getExt() + "@@@" + file.getFileId());
|
||||
}
|
||||
}
|
||||
if (item.getNextMarker().length() > 0) {
|
||||
|
|
@ -175,18 +183,19 @@ public class Ali {
|
|||
private void refreshAccessToken() {
|
||||
try {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("refresh_token", refreshToken);
|
||||
body.put("refresh_token", auth.getRefreshToken());
|
||||
body.put("grant_type", "refresh_token");
|
||||
JSONObject object = new JSONObject(post("https://auth.aliyundrive.com/v2/account/token", body));
|
||||
authorization = object.getString("token_type") + " " + object.getString("access_token");
|
||||
expiresTime = System.currentTimeMillis() + object.getInt("expires_in") * 1000L;
|
||||
refreshToken = object.getString("refresh_token");
|
||||
SpiderDebug.log("refresh token: " + refreshToken);
|
||||
auth.setAccessToken(object.getString("token_type") + " " + object.getString("access_token"));
|
||||
auth.setExpiresTime(System.currentTimeMillis() + object.getInt("expires_in") * 1000L);
|
||||
auth.setRefreshToken(object.getString("refresh_token"));
|
||||
SpiderDebug.log("refresh token: " + auth.getRefreshToken());
|
||||
} catch (JSONException e) {
|
||||
authorization = null;
|
||||
e.printStackTrace();
|
||||
checkService();
|
||||
auth.clean();
|
||||
getQRCode();
|
||||
} finally {
|
||||
while (auth.isEmpty()) SystemClock.sleep(250);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,15 +214,17 @@ public class Ali {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getSub(String shareId, String shareToken, String[] ids) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
private List<Sub> getSub(String shareId, String shareToken, String[] ids) {
|
||||
List<Sub> sub = new ArrayList<>();
|
||||
for (String text : ids) {
|
||||
if (!text.contains("@@@")) continue;
|
||||
String[] arr = text.split("@@@");
|
||||
String url = Proxy.getUrl() + "?do=ali&type=sub&share_id=" + shareId + "&share_token=" + shareToken + "&file_id=" + arr[1];
|
||||
sb.append(Trans.get(arr[0])).append("#").append(Misc.getSubMimeType(arr[2])).append("#").append(url).append("$$$");
|
||||
String[] split = text.split("@@@");
|
||||
String name = split[0];
|
||||
String ext = split[1];
|
||||
String url = Proxy.getUrl() + "?do=ali&type=sub&share_id=" + shareId + "&share_token=" + shareToken + "&file_id=" + split[2];
|
||||
sub.add(Sub.create().name(name).ext(ext).url(url));
|
||||
}
|
||||
return Misc.substring(sb.toString(), 3);
|
||||
return sub;
|
||||
}
|
||||
|
||||
private String getShareToken(String shareId) {
|
||||
|
|
@ -260,7 +271,7 @@ public class Ali {
|
|||
}
|
||||
}
|
||||
|
||||
private static String getDownloadUrl(String shareId, String shareToken, String fileId) {
|
||||
private String getDownloadUrl(String shareId, String shareToken, String fileId) {
|
||||
try {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("file_id", fileId);
|
||||
|
|
@ -277,7 +288,7 @@ public class Ali {
|
|||
}
|
||||
}
|
||||
|
||||
public static Object[] vod(Map<String, String> params) {
|
||||
public Object[] vod(Map<String, String> params) {
|
||||
String shareId = params.get("share_id");
|
||||
String shareToken = params.get("share_token");
|
||||
String fileId = params.get("file_id");
|
||||
|
|
@ -291,7 +302,7 @@ public class Ali {
|
|||
|
||||
private void checkService() {
|
||||
if (service != null) service.shutdownNow();
|
||||
if (view != null) Init.run(() -> Misc.removeView(view));
|
||||
if (auth.getView() != null) Init.run(() -> Misc.removeView(auth.getView()));
|
||||
}
|
||||
|
||||
private void getQRCode() {
|
||||
|
|
@ -310,15 +321,16 @@ public class Ali {
|
|||
}
|
||||
|
||||
private void setToken(String value) {
|
||||
Prefers.put("token", refreshToken = value);
|
||||
Prefers.put("token", value);
|
||||
Init.show("請重新進入播放頁");
|
||||
auth.setRefreshToken(value);
|
||||
checkService();
|
||||
}
|
||||
|
||||
private void showCode(Data data) {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.CENTER;
|
||||
Misc.addView(view = create(data.getData().getCodeContent()), params);
|
||||
Misc.addView(create(data.getData().getCodeContent()), params);
|
||||
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
||||
}
|
||||
|
||||
|
|
@ -326,6 +338,7 @@ public class Ali {
|
|||
ImageView view = new ImageView(Init.context());
|
||||
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
view.setImageBitmap(QRCode.getBitmap(value, 250, 2));
|
||||
auth.setView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ public class Init {
|
|||
|
||||
private final Handler handler;
|
||||
private Application app;
|
||||
private Ali ali;
|
||||
|
||||
private static class Loader {
|
||||
static volatile Init INSTANCE = new Init();
|
||||
|
|
@ -27,6 +28,7 @@ public class Init {
|
|||
}
|
||||
|
||||
public Init() {
|
||||
this.ali = new Ali();
|
||||
this.handler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +36,14 @@ public class Init {
|
|||
return get().app;
|
||||
}
|
||||
|
||||
public static Ali getAli() {
|
||||
return get().ali;
|
||||
}
|
||||
|
||||
public static void setAli(Ali ali) {
|
||||
get().ali = ali;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
||||
get().app = ((Application) context);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class PanSou extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class Paper extends Spider {
|
|||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
types = Arrays.asList("hyds", "rhds", "omds", "qtds", "hydy", "rhdy", "omdy", "qtdy", "hydm", "rhdm", "omdm", "jlp", "zyp", "jypx", "qtsp");
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class Proxy extends Spider {
|
|||
case "ck":
|
||||
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes("UTF-8"))};
|
||||
case "ali":
|
||||
return Ali.vod(params);
|
||||
return Init.getAli().vod(params);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class Push extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class UpYun extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,7 +46,7 @@ public class UpYun extends Spider {
|
|||
String url = apiUrl + "search?keyword=" + URLEncoder.encode(key) + "&page=1&s_type=2";
|
||||
String res = new String(Base64.decode(OkHttp.string(url, getHeaders()), Base64.DEFAULT));
|
||||
List<Vod> list = new ArrayList<>();
|
||||
for (Item item : Data.objectFrom(res).getResult().getItems()) if (item.isAli()) list.add(item.getVod());
|
||||
for (Item item : Data.objectFrom(res).getResult().getItems()) if (item.isAli() && item.getTitle().contains(key)) list.add(item.getVod());
|
||||
return Result.string(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class YiSo extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -45,7 +45,7 @@ public class YiSo extends Spider {
|
|||
Misc.loadWebView(url, getWebViewClient(result));
|
||||
while (!result.containsKey("json")) SystemClock.sleep(50);
|
||||
String json = JsonParser.parseString(Objects.requireNonNull(result.get("json"))).getAsJsonPrimitive().getAsString();
|
||||
return Result.string(Item.objectFrom(json).getData().getList());
|
||||
return Result.string(Item.objectFrom(json).getData().getList(key));
|
||||
}
|
||||
|
||||
private WebViewClient getWebViewClient(Map<String, String> result) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class Zhaozy extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ali = Init.getAli().token(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -78,6 +78,7 @@ public class Zhaozy extends Spider {
|
|||
Matcher matcher = regexVid.matcher(href);
|
||||
if (!matcher.find()) continue;
|
||||
String name = element.select("div.news_text a h3").text();
|
||||
if (!name.contains(key)) continue;
|
||||
String remark = element.select("div.news_text a p").text().split("\\|")[1].split(":")[1];
|
||||
Vod vod = new Vod();
|
||||
vod.setVodPic("https://inews.gtimg.com/newsapp_bt/0/13263837859/1000");
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.github.catvod.utils;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -41,12 +40,6 @@ public class Misc {
|
|||
return ext.equals("srt") || ext.equals("ass") || ext.equals("ssa");
|
||||
}
|
||||
|
||||
public static String getSubMimeType(String type) {
|
||||
if (type.equals("srt")) return "application/x-subrip";
|
||||
if (type.equals("ass") || type.equals("ssa")) return "text/x-ssa";
|
||||
return "application/x-subrip";
|
||||
}
|
||||
|
||||
public static String getSize(double size) {
|
||||
if (size == 0) return "";
|
||||
if (size > 1024 * 1024 * 1024 * 1024.0) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
945b391d7430796229f6d5309037abeb
|
||||
0c652bdac4683c84e151f867dd3abe54
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;945b391d7430796229f6d5309037abeb",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;0c652bdac4683c84e151f867dd3abe54",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"lives": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;945b391d7430796229f6d5309037abeb",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;0c652bdac4683c84e151f867dd3abe54",
|
||||
"wallpaper": "http://www.kf666888.cn/api/tvbox/img",
|
||||
"lives": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@
|
|||
},
|
||||
{
|
||||
"urls": [
|
||||
"http://baidu.douyincdn.freetvtv.com/tvbjade/m2.m3u8",
|
||||
"https://pull-l3-cny.douyincdn.com/live/e07fb43ab773bd88a01b9a96f354bfa9.m3u8",
|
||||
"http://113.64.147.149:808/hls/67/index.m3u8",
|
||||
"http://113.64.147.170:808/hls/67/index.m3u8"
|
||||
],
|
||||
|
|
@ -142,6 +144,7 @@
|
|||
},
|
||||
{
|
||||
"urls": [
|
||||
"https://pull-l3-cny.douyincdn.com/live/281ad35ffd611b16b5d4b4e55d86de69.m3u8",
|
||||
"http://198.16.64.10:8278/j2_twn/playlist.m3u8?tid=MA8A1176878411768784&ct=19225&tsum=fea41bb592165942b9971148376f8b70",
|
||||
"http://198.16.64.10:8278/j2_twn/playlist.m3u8?tid=m22905da1d346&ct=18336&tsum=3b4998c4f5367bb820165f66b0caab0e",
|
||||
"http://120.84.96.196:808/hls/86/index.m3u8",
|
||||
|
|
@ -204,6 +207,7 @@
|
|||
},
|
||||
{
|
||||
"urls": [
|
||||
"http://baidu.douyincdn.freetvtv.com/vius/m2.m3u8",
|
||||
"http://198.16.64.10:8278/viu_twn/playlist.m3u8?tid=MF2F6219999362199993&ct=19225&tsum=0315b071e42f6b8b6f49b6ca58b7393b"
|
||||
],
|
||||
"number": "019",
|
||||
|
|
@ -295,6 +299,7 @@
|
|||
},
|
||||
{
|
||||
"urls": [
|
||||
"https://pull-l3-cny.douyincdn.com/live/8f0f5b53f8ad921929fc9ac8771cbd82.m3u8",
|
||||
"http://198.16.64.10:8278/Wlt/playlist.m3u8?tid=MC9C7523788875237888&ct=19225&tsum=fc74aa160d3ca61369c2e5f3ae79ee8e"
|
||||
],
|
||||
"number": "028",
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ plugins {
|
|||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
@ -13,9 +13,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class Run {
|
||||
|
||||
private final List<Group> groups;
|
||||
|
|
@ -23,7 +20,7 @@ public class Run {
|
|||
private final Gson gson;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
new Run().start();
|
||||
new Run().start("http://home.jundie.top:81/Cat/tv/live.txt");
|
||||
}
|
||||
|
||||
public Run() {
|
||||
|
|
@ -32,14 +29,13 @@ public class Run {
|
|||
gson = new Gson().newBuilder().disableHtmlEscaping().setPrettyPrinting().create();
|
||||
}
|
||||
|
||||
private void start() throws IOException {
|
||||
parseOnline(new OkHttpClient().newCall(new Request.Builder().url("http://home.jundie.top:81/Cat/tv/live.txt").build()).execute().body().string());
|
||||
private void start(String text) throws IOException {
|
||||
//parseTxt(Util.getFile(getClass(), "live.txt"));
|
||||
System.out.println(gson.toJson(groups));
|
||||
parse(Util.call(text));
|
||||
writeFile();
|
||||
}
|
||||
|
||||
private void parseOnline(String text) {
|
||||
private void parse(String text) {
|
||||
for (String line : text.split("\n")) {
|
||||
String[] split = line.split(",");
|
||||
if (split.length < 2) continue;
|
||||
|
|
@ -79,8 +75,8 @@ public class Run {
|
|||
private void combine(Channel channel) {
|
||||
for (Data item : data) {
|
||||
if (item.getName().contains(channel.getName())) {
|
||||
channel.epg(item.getEpgid());
|
||||
channel.logo(item.getLogo());
|
||||
channel.epg(item.getEpg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,39 @@
|
|||
package com.fongmi.tools;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static String getFile(Class<?> clz, String fileName) {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
URI uri = clz.getClassLoader().getResource(fileName).toURI();
|
||||
Stream<String> stream = Files.lines(Paths.get(uri), StandardCharsets.UTF_8);
|
||||
stream.forEach(s -> sb.append(s).append("\n"));
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public static String call(String url) throws IOException {
|
||||
return new OkHttpClient().newCall(new Request.Builder().url(url).build()).execute().body().string();
|
||||
}
|
||||
|
||||
public static String getFile(Class<?> clz, String fileName) {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
URI uri = clz.getClassLoader().getResource(fileName).toURI();
|
||||
Stream<String> stream = Files.lines(Paths.get(uri), StandardCharsets.UTF_8);
|
||||
stream.forEach(s -> sb.append(s).append("\n"));
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFile(String fileName) {
|
||||
try {
|
||||
return Files.readString(Path.of(fileName));
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,74 +10,28 @@ import java.util.List;
|
|||
|
||||
public class Data {
|
||||
|
||||
@SerializedName("tvid")
|
||||
private String tvid;
|
||||
@SerializedName("epgid")
|
||||
private String epgid;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("status")
|
||||
private String status;
|
||||
@SerializedName("note")
|
||||
private String note;
|
||||
@SerializedName("logo")
|
||||
private String logo;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("epg")
|
||||
private String epg;
|
||||
|
||||
public static Data objectFrom(String str) {
|
||||
return new Gson().fromJson(str, Data.class);
|
||||
}
|
||||
@SerializedName("logo")
|
||||
private String logo;
|
||||
|
||||
public static List<Data> arrayFrom(String str) {
|
||||
Type listType = new TypeToken<ArrayList<Data>>() {
|
||||
}.getType();
|
||||
return new Gson().fromJson(str, listType);
|
||||
}
|
||||
public static List<Data> arrayFrom(String str) {
|
||||
Type listType = new TypeToken<ArrayList<Data>>() {}.getType();
|
||||
return new Gson().fromJson(str, listType);
|
||||
}
|
||||
|
||||
public String getTvid() {
|
||||
return tvid;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setTvid(String tvid) {
|
||||
this.tvid = tvid;
|
||||
}
|
||||
public String getEpg() {
|
||||
return epg;
|
||||
}
|
||||
|
||||
public String getEpgid() {
|
||||
return epgid;
|
||||
}
|
||||
|
||||
public void setEpgid(String epgid) {
|
||||
this.epgid = epgid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue