pull/586/head
FongMi 1 year ago
parent 4ecae710d5
commit 000a5879ca
  1. 5
      app/src/main/java/com/fongmi/android/tv/api/LiveParser.java
  2. 14
      app/src/main/java/com/fongmi/android/tv/api/XtreamParser.java
  3. 2
      app/src/main/java/com/fongmi/android/tv/api/config/LiveConfig.java
  4. 4
      app/src/main/java/com/fongmi/android/tv/bean/Live.java

@ -52,8 +52,8 @@ public class LiveParser {
public static void text(Live live, String text) {
int number = 0;
if (!live.getGroups().isEmpty()) return;
if (M3U.matcher(text).find()) m3u(live, text);
else if (live.isXtream()) xtream(live);
if (text.isEmpty() && live.isXtream()) xtream(live);
else if (M3U.matcher(text).find()) m3u(live, text);
else txt(live, text);
for (Group group : live.getGroups()) {
for (Channel channel : group.getChannel()) {
@ -146,6 +146,7 @@ public class LiveParser {
}
private static String getText(Live live) {
if (XtreamParser.isApiUrl(live.getUrl())) return "";
return getText(live.getUrl(), live.getHeaders()).replace("\r\n", "\n");
}

@ -18,8 +18,20 @@ public class XtreamParser {
return new HttpUrl.Builder().scheme(url.scheme()).host(url.host()).port(url.port());
}
public static boolean isVerify(Uri uri) {
return isApiUrl(uri) || isGetUrl(uri);
}
public static boolean isApiUrl(String url) {
return isApiUrl(Uri.parse(url));
}
public static boolean isApiUrl(Uri uri) {
return uri.getPath() != null && (uri.getPath().contains("get.php") || uri.getPath().contains("player_api.php"));
return uri.getPath() != null && uri.getPath().contains("player_api.php") && uri.getQueryParameter("username") != null && uri.getQueryParameter("password") != null;
}
public static boolean isGetUrl(Uri uri) {
return uri.getPath() != null && uri.getPath().contains("get.php") && uri.getQueryParameter("username") != null && uri.getQueryParameter("password") != null;
}
public static String getEpgUrl(Live live) {

@ -114,7 +114,7 @@ public class LiveConfig {
private void loadConfig(Callback callback) {
try {
boolean xtream = XtreamParser.isApiUrl(Uri.parse(config.getUrl()));
boolean xtream = XtreamParser.isApiUrl(config.getUrl());
parseConfig(xtream ? "" : Decoder.getJson(config.getUrl()), callback);
} catch (Throwable e) {
if (TextUtils.isEmpty(config.getUrl())) App.post(() -> callback.error(""));

@ -333,10 +333,10 @@ public class Live {
public Live check() {
Uri uri = Uri.parse(getUrl());
boolean xtream = XtreamParser.isApiUrl(uri);
boolean xtream = XtreamParser.isVerify(uri);
if (xtream) setUsername(uri.getQueryParameter("username"));
if (xtream) setPassword(uri.getQueryParameter("password"));
if (isXtream() && getEpg().isEmpty()) setEpg(XtreamParser.getEpgUrl(this));
if (xtream && getEpg().isEmpty()) setEpg(XtreamParser.getEpgUrl(this));
return this;
}

Loading…
Cancel
Save