|
|
|
|
@ -1,35 +1,19 @@ |
|
|
|
|
package com.github.catvod.utils; |
|
|
|
|
|
|
|
|
|
import android.net.Uri; |
|
|
|
|
import android.os.Build; |
|
|
|
|
import android.provider.Settings; |
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
import android.util.Base64; |
|
|
|
|
|
|
|
|
|
import com.github.catvod.Init; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.math.BigInteger; |
|
|
|
|
import java.security.MessageDigest; |
|
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Formatter; |
|
|
|
|
|
|
|
|
|
public class Util { |
|
|
|
|
|
|
|
|
|
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"; |
|
|
|
|
|
|
|
|
|
public static String getDeviceId() { |
|
|
|
|
return Settings.Secure.getString(Init.context().getContentResolver(), Settings.Secure.ANDROID_ID); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getDeviceName() { |
|
|
|
|
String model = Build.MODEL; |
|
|
|
|
String manufacturer = Build.MANUFACTURER; |
|
|
|
|
return model.startsWith(manufacturer) ? model : manufacturer + " " + model; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String base64(String ext) { |
|
|
|
|
return base64(ext.getBytes()); |
|
|
|
|
} |
|
|
|
|
@ -38,42 +22,14 @@ public class Util { |
|
|
|
|
return Base64.encodeToString(bytes, Base64.DEFAULT | Base64.NO_WRAP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String substring(String text) { |
|
|
|
|
return substring(text, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String substring(String text, int num) { |
|
|
|
|
if (text != null && text.length() > num) return text.substring(0, text.length() - num); |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String scheme(String url) { |
|
|
|
|
return url == null ? "" : scheme(Uri.parse(url)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String scheme(Uri uri) { |
|
|
|
|
String scheme = uri.getScheme(); |
|
|
|
|
return scheme == null ? "" : scheme.toLowerCase().trim(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String host(String url) { |
|
|
|
|
return url == null ? "" : host(Uri.parse(url)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String host(Uri uri) { |
|
|
|
|
String host = uri.getHost(); |
|
|
|
|
return host == null ? "" : host.toLowerCase().trim(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String path(Uri uri) { |
|
|
|
|
String path = uri.getPath(); |
|
|
|
|
return path == null ? "" : path.trim(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String basic(Uri uri) { |
|
|
|
|
return "Basic " + base64(uri.getUserInfo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean equals(String name, String md5) { |
|
|
|
|
return md5(Path.jar(name)).equalsIgnoreCase(md5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String md5(String src) { |
|
|
|
|
try { |
|
|
|
|
if (TextUtils.isEmpty(src)) return ""; |
|
|
|
|
@ -104,10 +60,6 @@ public class Util { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean equals(String name, String md5) { |
|
|
|
|
return md5(Path.jar(name)).equalsIgnoreCase(md5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean containOrMatch(String text, String regex) { |
|
|
|
|
try { |
|
|
|
|
return text.contains(regex) || text.matches(regex); |
|
|
|
|
@ -115,20 +67,4 @@ public class Util { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static long format(SimpleDateFormat format, String src) { |
|
|
|
|
try { |
|
|
|
|
return format.parse(src).getTime(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String format(StringBuilder builder, Formatter formatter, long timeMs) { |
|
|
|
|
try { |
|
|
|
|
return androidx.media3.common.util.Util.getStringForTime(builder, formatter, timeMs); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|