From 7fff4c678f545f930d92b548f4b1b4f6d4cebd24 Mon Sep 17 00:00:00 2001 From: FongMi Date: Thu, 18 May 2023 22:23:58 +0800 Subject: [PATCH] Fix bug --- app/build.gradle | 4 ++-- .../com/fongmi/android/tv/utils/Sniffer.java | 22 ++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c0112562f..88ba9f005 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java b/app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java index 14fc2011e..0dfb1e5ea 100644 --- a/app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java +++ b/app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java @@ -19,24 +19,20 @@ public class Sniffer { } public static boolean isVideo(String url, Map 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; } }