pull/123/head
FongMi 3 years ago
parent 903f394958
commit 7fff4c678f
  1. 4
      app/build.gradle
  2. 22
      app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java

@ -22,12 +22,12 @@ android {
leanback {
dimension "mode"
versionCode 76
versionName "20230518#3"
versionName "20230518#4"
}
mobile {
dimension "mode"
versionCode 14
versionName "20230518#3"
versionName "20230518#4"
}
java {
dimension "api"

@ -19,24 +19,20 @@ public class Sniffer {
}
public static boolean isVideo(String url, Map<String, String> headers) {
if (match(url)) return true;
if (matchOrContain(url)) return true;
if (headers.containsKey("Accept") && headers.get("Accept").startsWith("image")) return false;
if (url.contains("url=http") || url.contains("v=http") || url.contains(".css") || url.contains(".html")) return false;
return RULE.matcher(url).find();
return match(url) || RULE.matcher(url).find();
}
private static boolean match(String url) {
private static boolean matchOrContain(String url) {
Uri uri = Uri.parse(url);
for (Rule rule : ApiConfig.get().getRules()) {
for (String host : rule.getHosts()) {
if (uri.getHost().contains(host)) {
for (String regex : rule.getRegex()) return Pattern.compile(regex).matcher(url).find() || url.contains(regex);
}
if (host.equals("*")) {
for (String regex : rule.getRegex()) return Pattern.compile(regex).matcher(url).find();
}
}
}
for (Rule rule : ApiConfig.get().getRules()) for (String host : rule.getHosts()) if (uri.getHost().contains(host)) for (String regex : rule.getRegex()) return Pattern.compile(regex).matcher(url).find() || url.contains(regex);
return false;
}
private static boolean match(String url) {
for (Rule rule : ApiConfig.get().getRules()) for (String host : rule.getHosts()) if (host.equals("*")) for (String regex : rule.getRegex()) return Pattern.compile(regex).matcher(url).find();
return false;
}
}

Loading…
Cancel
Save