Clean code
This commit is contained in:
parent
6f03a1323d
commit
069b641b04
|
|
@ -3,6 +3,7 @@ package com.github.catvod.bean.bili;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.github.catvod.utils.Crypto;
|
||||||
import com.github.catvod.utils.Util;
|
import com.github.catvod.utils.Util;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
|
@ -41,7 +42,7 @@ public class Wbi {
|
||||||
params.put("wts", System.currentTimeMillis() / 1000);
|
params.put("wts", System.currentTimeMillis() / 1000);
|
||||||
for (String key : params.keySet()) sb.append(key).append("=").append(URLEncoder.encode(params.get(key).toString())).append("&");
|
for (String key : params.keySet()) sb.append(key).append("=").append(URLEncoder.encode(params.get(key).toString())).append("&");
|
||||||
String query = Util.substring(sb.toString());
|
String query = Util.substring(sb.toString());
|
||||||
String w_rid = Util.MD5(query + mixinKey);
|
String w_rid = Crypto.md5(query + mixinKey);
|
||||||
return query + "&w_rid=" + w_rid;
|
return query + "&w_rid=" + w_rid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Util;
|
import com.github.catvod.utils.Crypto;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
@ -37,7 +37,7 @@ public class AppXY extends Spider {
|
||||||
public void init(Context context, String extend) throws Exception {
|
public void init(Context context, String extend) throws Exception {
|
||||||
String s = System.currentTimeMillis() + "";
|
String s = System.currentTimeMillis() + "";
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("device", Util.MD5(s));
|
map.put("device", Crypto.md5(s));
|
||||||
map.put("install_first_open", "true");
|
map.put("install_first_open", "true");
|
||||||
map.put("first_install_time", s);
|
map.put("first_install_time", s);
|
||||||
map.put("last_update_time", s);
|
map.put("last_update_time", s);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import android.os.SystemClock;
|
||||||
|
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.FileUtil;
|
||||||
import com.github.catvod.utils.Path;
|
import com.github.catvod.utils.Path;
|
||||||
import com.github.catvod.utils.Shell;
|
import com.github.catvod.utils.Shell;
|
||||||
import com.github.catvod.utils.Util;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -53,7 +53,7 @@ public class Feiyang extends Spider {
|
||||||
String url = texts[0].trim();
|
String url = texts[0].trim();
|
||||||
String md5 = texts[1].trim();
|
String md5 = texts[1].trim();
|
||||||
if (md5.startsWith("http")) md5 = OkHttp.string(md5).trim();
|
if (md5.startsWith("http")) md5 = OkHttp.string(md5).trim();
|
||||||
if (Util.MD5(f_aio).equals(md5)) return;
|
if (FileUtil.md5(f_aio).equals(md5)) return;
|
||||||
try {
|
try {
|
||||||
File file = Path.create(new File(Path.download(), AIO));
|
File file = Path.create(new File(Path.download(), AIO));
|
||||||
download(file, OkHttp.newCall(url).body().byteStream());
|
download(file, OkHttp.newCall(url).body().byteStream());
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.Crypto;
|
||||||
import com.github.catvod.utils.LZString;
|
import com.github.catvod.utils.LZString;
|
||||||
import com.github.catvod.utils.Util;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
@ -242,8 +242,8 @@ public class Living extends Spider {
|
||||||
String f = String.valueOf(currentTimeMillis + Long.parseLong(N));
|
String f = String.valueOf(currentTimeMillis + Long.parseLong(N));
|
||||||
String fmPart = code.split("fm=")[1].split("&")[0];
|
String fmPart = code.split("fm=")[1].split("&")[0];
|
||||||
String c = new String(Base64.decode(URLDecoder.decode(fmPart, "UTF-8"), Base64.NO_WRAP)).split("_")[0];
|
String c = new String(Base64.decode(URLDecoder.decode(fmPart, "UTF-8"), Base64.NO_WRAP)).split("_")[0];
|
||||||
String u = Util.MD5(f + "|tars_mp|102");
|
String u = Crypto.md5(f + "|tars_mp|102");
|
||||||
return String.format("&wsSecret=%s&uuid=%s&wsTime=%s&uid=%s&seqid=%s&fs=%s&ctype=tars_mp&t=102&ver=1&sv=2401310321", Util.MD5(c + "_" + N + "_" + name + "_" + u + "_" + s), i, s, N, f, r);
|
return String.format("&wsSecret=%s&uuid=%s&wsTime=%s&uid=%s&seqid=%s&fs=%s&ctype=tars_mp&t=102&ver=1&sv=2401310321", Crypto.md5(c + "_" + N + "_" + name + "_" + u + "_" + s), i, s, N, f, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject request(String url) throws JSONException {
|
private JSONObject request(String url) throws JSONException {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class Uvod extends Spider {
|
||||||
} else if (URL.equals(play)) {
|
} else if (URL.equals(play)) {
|
||||||
text = String.format("-quality=%s&video_fragment_id=%s&video_id=%s-%s", quality, pg, tid, hm);
|
text = String.format("-quality=%s&video_fragment_id=%s&video_id=%s-%s", quality, pg, tid, hm);
|
||||||
}
|
}
|
||||||
String sign = Util.MD5(text);
|
String sign = Crypto.md5(text);
|
||||||
Map<String, String> header = new HashMap<>();
|
Map<String, String> header = new HashMap<>();
|
||||||
header.put("User-Agent", Util.CHROME);
|
header.put("User-Agent", Util.CHROME);
|
||||||
header.put("referer", "https://www.uvod.tv/");
|
header.put("referer", "https://www.uvod.tv/");
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Qile
|
* @author Qile
|
||||||
|
|
@ -106,10 +108,10 @@ public class YHDM extends Spider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String text = doc.select(".myui-content__detail").text();
|
String text = doc.select(".myui-content__detail").text();
|
||||||
String classifyName = Util.Matcher(text, "类型:(.*?)分类");
|
String classifyName = matcher(text, "类型:(.*?)分类");
|
||||||
String area = Util.Matcher(text, "地区:(.*?)年份");
|
String area = matcher(text, "地区:(.*?)年份");
|
||||||
String year = Util.Matcher(text, "年份:(.*?)更新");
|
String year = matcher(text, "年份:(.*?)更新");
|
||||||
String remark = Util.Matcher(text, "更新:(.*?)简介");
|
String remark = matcher(text, "更新:(.*?)简介");
|
||||||
String brief = doc.select(".col-pd.text-collapse .data").text();
|
String brief = doc.select(".col-pd.text-collapse .data").text();
|
||||||
|
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
|
|
@ -147,22 +149,27 @@ public class YHDM extends Spider {
|
||||||
String ConfigUrl = siteUrl + "/static/js/playerconfig.js?t=" + todayDate;
|
String ConfigUrl = siteUrl + "/static/js/playerconfig.js?t=" + todayDate;
|
||||||
if (!configCache.containsKey(ConfigUrl)) {
|
if (!configCache.containsKey(ConfigUrl)) {
|
||||||
String ConfigContent = OkHttp.string(ConfigUrl, getHeader());
|
String ConfigContent = OkHttp.string(ConfigUrl, getHeader());
|
||||||
String ConfigObject = Util.Matcher(ConfigContent, "player_list=(.*?),MacPlayerConfig");
|
String ConfigObject = matcher(ConfigContent, "player_list=(.*?),MacPlayerConfig");
|
||||||
configCache.put(ConfigUrl, ConfigObject);
|
configCache.put(ConfigUrl, ConfigObject);
|
||||||
}
|
}
|
||||||
String content = OkHttp.string(siteUrl + id, getHeader());
|
String content = OkHttp.string(siteUrl + id, getHeader());
|
||||||
String json = Util.Matcher(content, "player_aaaa=(.*?)</script>");
|
String json = matcher(content, "player_aaaa=(.*?)</script>");
|
||||||
JSONObject player = new JSONObject(json);
|
JSONObject player = new JSONObject(json);
|
||||||
String aaaaUrl = player.getString("url");
|
String aaaaUrl = player.getString("url");
|
||||||
String from = player.getString("from");
|
String from = player.getString("from");
|
||||||
String parseUrl = new JSONObject(configCache.get(ConfigUrl)).getJSONObject(from).getString("parse");
|
String parseUrl = new JSONObject(configCache.get(ConfigUrl)).getJSONObject(from).getString("parse");
|
||||||
String parseUrls = parseUrl + aaaaUrl;
|
String parseUrls = parseUrl + aaaaUrl;
|
||||||
String content1 = OkHttp.string(parseUrls, getHeader());
|
String content1 = OkHttp.string(parseUrls, getHeader());
|
||||||
String playUrl = Util.Matcher(content1, "getVideoInfo\\(\"(.*?)\"");
|
String playUrl = matcher(content1, "getVideoInfo\\(\"(.*?)\"");
|
||||||
String key = "57A891D97E332A9D";
|
String key = "57A891D97E332A9D";
|
||||||
String iv = Util.Matcher(content1, "bt_token = \"(.*?)\"");
|
String iv = matcher(content1, "bt_token = \"(.*?)\"");
|
||||||
String realUrl = Crypto.CBC(playUrl, key, iv);
|
String realUrl = Crypto.CBC(playUrl, key, iv);
|
||||||
if (realUrl == null) return Result.get().url(siteUrl + id).parse().string();
|
if (realUrl == null) return Result.get().url(siteUrl + id).parse().string();
|
||||||
return Result.get().url(realUrl).string();
|
return Result.get().url(realUrl).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String matcher(String content, String pattern) {
|
||||||
|
Matcher matcher = Pattern.compile(pattern).matcher(content);
|
||||||
|
return matcher.find() ? matcher.group(1) : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
package com.github.catvod.ui;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.text.TextPaint;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.animation.LinearInterpolator;
|
|
||||||
import android.widget.Scroller;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
public class ScrollTextView extends TextView {
|
|
||||||
|
|
||||||
private final Scroller scroller;
|
|
||||||
private int duration;
|
|
||||||
|
|
||||||
public ScrollTextView(Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrollTextView(Context context, AttributeSet attrs) {
|
|
||||||
this(context, attrs, android.R.attr.textViewStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrollTextView(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
setSingleLine();
|
|
||||||
setEllipsize(null);
|
|
||||||
setHorizontallyScrolling(true);
|
|
||||||
setScroller(scroller = new Scroller(getContext(), new LinearInterpolator()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(int duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startScroll() {
|
|
||||||
scroller.startScroll(-getWidth(), 0, calculateScrollingLen(), 0, duration * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopScroll() {
|
|
||||||
if (scroller != null) scroller.abortAnimation();
|
|
||||||
setVisibility(GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateScrollingLen() {
|
|
||||||
TextPaint paint = getPaint();
|
|
||||||
Rect rect = new Rect();
|
|
||||||
String text = getText().toString();
|
|
||||||
paint.getTextBounds(text, 0, text.length(), rect);
|
|
||||||
return rect.width() + getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void computeScroll() {
|
|
||||||
super.computeScroll();
|
|
||||||
if (scroller != null && scroller.isFinished()) stopScroll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,10 @@ package com.github.catvod.utils;
|
||||||
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
|
|
@ -16,6 +18,23 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
public class Crypto {
|
public class Crypto {
|
||||||
|
|
||||||
|
public static String md5(String src) {
|
||||||
|
return md5(src, "UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String md5(String src, String charset) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] messageDigest = md.digest(src.getBytes(charset));
|
||||||
|
BigInteger no = new BigInteger(1, messageDigest);
|
||||||
|
StringBuilder sb = new StringBuilder(no.toString(16));
|
||||||
|
while (sb.length() < 32) sb.insert(0, "0");
|
||||||
|
return sb.toString().toLowerCase();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String CBC(String src, String KEY, String IV) {
|
public static String CBC(String src, String KEY, String IV) {
|
||||||
try {
|
try {
|
||||||
src = src.replace("\\", "");
|
src = src.replace("\\", "");
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ import android.text.TextUtils;
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
@ -37,6 +39,22 @@ public class FileUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String md5(File file) {
|
||||||
|
try {
|
||||||
|
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
byte[] bytes = new byte[4096];
|
||||||
|
int count;
|
||||||
|
while ((count = fis.read(bytes)) != -1) digest.update(bytes, 0, count);
|
||||||
|
fis.close();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : digest.digest()) sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||||
|
return sb.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Uri getShareUri(File file) {
|
private static Uri getShareUri(File file) {
|
||||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.N ? Uri.fromFile(file) : FileProvider.getUriForFile(Init.context(), Init.context().getPackageName() + ".provider", file);
|
return Build.VERSION.SDK_INT < Build.VERSION_CODES.N ? Uri.fromFile(file) : FileProvider.getUriForFile(Init.context(), Init.context().getPackageName() + ".provider", file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
package com.github.catvod.utils;
|
|
||||||
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.github.catvod.net.OkHttp;
|
|
||||||
import com.github.catvod.spider.Proxy;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import okhttp3.Response;
|
|
||||||
|
|
||||||
public class ProxyVideo {
|
|
||||||
|
|
||||||
private static final String GO_SERVER = "http://127.0.0.1:7777/";
|
|
||||||
|
|
||||||
public static void go() {
|
|
||||||
boolean close = OkHttp.string(GO_SERVER).isEmpty();
|
|
||||||
if (close) OkHttp.string("http://127.0.0.1:" + Proxy.getPort() + "/go");
|
|
||||||
if (close) while (OkHttp.string(GO_SERVER).isEmpty()) SystemClock.sleep(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String goVer() {
|
|
||||||
try {
|
|
||||||
go();
|
|
||||||
String result = OkHttp.string(GO_SERVER + "version");
|
|
||||||
return new JSONObject(result).optString("version");
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String url(String url, int thread) {
|
|
||||||
if (!TextUtils.isEmpty(goVer()) && url.contains("/proxy?")) url += "&response=url";
|
|
||||||
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object[] proxy(String url, Map<String, String> headers) throws Exception {
|
|
||||||
Response response = OkHttp.newCall(url, headers);
|
|
||||||
String contentType = response.headers().get("Content-Type");
|
|
||||||
String contentDisposition = response.headers().get("Content-Disposition");
|
|
||||||
if (contentDisposition != null) contentType = getMimeType(contentDisposition);
|
|
||||||
Map<String, String> respHeaders = new HashMap<>();
|
|
||||||
for (String key : response.headers().names()) respHeaders.put(key, response.headers().get(key));
|
|
||||||
return new Object[]{206, contentType, response.body().byteStream(), respHeaders};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getMimeType(String contentDisposition) {
|
|
||||||
if (contentDisposition.endsWith(".mp4")) {
|
|
||||||
return "video/mp4";
|
|
||||||
} else if (contentDisposition.endsWith(".webm")) {
|
|
||||||
return "video/webm";
|
|
||||||
} else if (contentDisposition.endsWith(".avi")) {
|
|
||||||
return "video/x-msvideo";
|
|
||||||
} else if (contentDisposition.endsWith(".wmv")) {
|
|
||||||
return "video/x-ms-wmv";
|
|
||||||
} else if (contentDisposition.endsWith(".flv")) {
|
|
||||||
return "video/x-flv";
|
|
||||||
} else if (contentDisposition.endsWith(".mov")) {
|
|
||||||
return "video/quicktime";
|
|
||||||
} else if (contentDisposition.endsWith(".mkv")) {
|
|
||||||
return "video/x-matroska";
|
|
||||||
} else if (contentDisposition.endsWith(".mpeg")) {
|
|
||||||
return "video/mpeg";
|
|
||||||
} else if (contentDisposition.endsWith(".3gp")) {
|
|
||||||
return "video/3gpp";
|
|
||||||
} else if (contentDisposition.endsWith(".ts")) {
|
|
||||||
return "video/MP2T";
|
|
||||||
} else if (contentDisposition.endsWith(".mp3")) {
|
|
||||||
return "audio/mp3";
|
|
||||||
} else if (contentDisposition.endsWith(".wav")) {
|
|
||||||
return "audio/wav";
|
|
||||||
} else if (contentDisposition.endsWith(".aac")) {
|
|
||||||
return "audio/aac";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,12 +15,10 @@ import com.github.catvod.spider.Init;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
@ -38,12 +36,6 @@ public class Util {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlackVodUrl(String url) {
|
|
||||||
List<String> hosts = Arrays.asList("973973.xyz", ".fit:");
|
|
||||||
for (String host : hosts) if (url.contains(host)) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isThunder(String url) {
|
public static boolean isThunder(String url) {
|
||||||
return THUNDER.matcher(url).find() || isTorrent(url);
|
return THUNDER.matcher(url).find() || isTorrent(url);
|
||||||
}
|
}
|
||||||
|
|
@ -125,39 +117,6 @@ public class Util {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String MD5(File file) {
|
|
||||||
try {
|
|
||||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
|
||||||
FileInputStream fis = new FileInputStream(file);
|
|
||||||
byte[] bytes = new byte[4096];
|
|
||||||
int count;
|
|
||||||
while ((count = fis.read(bytes)) != -1) digest.update(bytes, 0, count);
|
|
||||||
fis.close();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (byte b : digest.digest()) sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
|
||||||
return sb.toString();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String MD5(String src) {
|
|
||||||
return MD5(src, "UTF-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String MD5(String src, String charset) {
|
|
||||||
try {
|
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
||||||
byte[] messageDigest = md.digest(src.getBytes(charset));
|
|
||||||
BigInteger no = new BigInteger(1, messageDigest);
|
|
||||||
StringBuilder sb = new StringBuilder(no.toString(16));
|
|
||||||
while (sb.length() < 32) sb.insert(0, "0");
|
|
||||||
return sb.toString().toLowerCase();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copy(String text) {
|
public static void copy(String text) {
|
||||||
ClipboardManager manager = (ClipboardManager) Init.context().getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager manager = (ClipboardManager) Init.context().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
manager.setPrimaryClip(ClipData.newPlainText("fongmi", text));
|
manager.setPrimaryClip(ClipData.newPlainText("fongmi", text));
|
||||||
|
|
@ -205,22 +164,4 @@ public class Util {
|
||||||
webView.loadUrl(url);
|
webView.loadUrl(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDigit(String text) {
|
|
||||||
try {
|
|
||||||
String newText = text;
|
|
||||||
Matcher matcher = Pattern.compile(".*(1080|720|2160|4k|4K).*").matcher(text);
|
|
||||||
if (matcher.find()) newText = matcher.group(1) + " " + text;
|
|
||||||
matcher = Pattern.compile("^([0-9]+)").matcher(text);
|
|
||||||
if (matcher.find()) newText = matcher.group(1) + " " + newText;
|
|
||||||
return newText.replaceAll("\\D+", "") + " " + newText.replaceAll("\\d+", "");
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String Matcher(String content, String pattern) {
|
|
||||||
Matcher matcher = Pattern.compile(pattern).matcher(content);
|
|
||||||
return matcher.find() ? matcher.group(1) : "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
41d830d74afd5a31464b2f6678cd3f2e
|
3cbe660633a395f10a0ae0ee543e935a
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue