Fix live bug

pull/568/head
okjack 1 year ago
parent 666a87c0c3
commit bc3ed5fdb0
  1. 13
      app/src/main/java/com/fongmi/android/tv/api/config/LiveConfig.java
  2. 7
      app/src/main/java/com/fongmi/android/tv/bean/Live.java

@ -1,5 +1,6 @@
package com.fongmi.android.tv.api.config;
import android.net.Uri;
import android.text.TextUtils;
import com.fongmi.android.tv.App;
@ -25,6 +26,7 @@ import com.github.catvod.utils.Json;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -128,13 +130,22 @@ public class LiveConfig {
}
private void parseText(String text, Callback callback) {
Live live = new Live(config.getUrl()).sync();
Live live = new Live(parseName(config.getUrl()), config.getUrl()).sync();
LiveParser.text(live, text);
lives.add(live);
setHome(live, true);
App.post(callback::success);
}
private String parseName(String url) {
Uri uri = Uri.parse(url);
if ("file".equals(uri.getScheme())) return new File(url).getName();
if (uri.getLastPathSegment() != null) return uri.getLastPathSegment();
if (uri.getQuery() != null) return uri.getQuery();
if (uri.getHost() != null) return uri.getHost();
return url;
}
private void checkJson(JsonObject object, Callback callback) {
if (object.has("msg") && callback != null) {
App.post(() -> callback.error(object.get("msg").getAsString()));

@ -1,6 +1,5 @@
package com.fongmi.android.tv.bean;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.NonNull;
@ -22,7 +21,6 @@ import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
@ -137,11 +135,6 @@ public class Live {
public Live() {
}
public Live(String url) {
this.name = url.startsWith("file") ? new File(url).getName() : Uri.parse(url).getLastPathSegment();
this.url = url;
}
public Live(@NonNull String name, String url) {
this.name = name;
this.url = url;

Loading…
Cancel
Save