pull/589/head
FongMi 1 year ago
parent 8548b5f731
commit 32294e73be
  1. 1
      app/src/main/java/com/fongmi/android/tv/api/EpgParser.java
  2. 2
      app/src/main/java/com/fongmi/android/tv/bean/Channel.java
  3. 11
      app/src/main/java/com/fongmi/android/tv/bean/Live.java
  4. 2
      app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java

@ -32,7 +32,6 @@ public class EpgParser {
private static final SimpleDateFormat formatFull = new SimpleDateFormat("yyyyMMddHHmmss Z", Locale.getDefault());
public static boolean start(Live live, String url) throws Exception {
if (!url.contains("xml") && !url.contains("gz")) return false;
File file = Path.epg(Uri.parse(url).getLastPathSegment());
if (shouldDownload(file)) Download.create(url, file).start();
if (file.getName().endsWith(".gz")) readGzip(live, file);

@ -326,7 +326,7 @@ public class Channel {
if (!live.getOrigin().isEmpty() && getOrigin().isEmpty()) setOrigin(live.getOrigin());
if (!live.getCatchup().isEmpty() && getCatchup().isEmpty()) setCatchup(live.getCatchup());
if (!live.getReferer().isEmpty() && getReferer().isEmpty()) setReferer(live.getReferer());
if (live.getEpg().contains("{") && !getEpg().startsWith("http")) setEpg(live.getEpg().replace("{name}", getTvgName()).replace("{epg}", getEpg()));
if (live.getEpg().contains("{") && !getEpg().startsWith("http")) setEpg(live.getEpgApi().replace("{name}", getTvgName()).replace("{epg}", getEpg()));
if (live.getLogo().contains("{") && !getLogo().startsWith("http")) setLogo(live.getLogo().replace("{name}", getTvgName()).replace("{logo}", getLogo()));
}

@ -275,6 +275,17 @@ public class Live {
this.width = width;
}
public String getEpgApi() {
for (String url : getEpg().split(",")) if (url.contains("{")) return url;
return getEpg();
}
public List<String> getEpgXml() {
List<String> items = new ArrayList<>();
for (String epg : getEpg().split(",")) if (!epg.contains("{") && (epg.contains("xml") || epg.contains("gz"))) items.add(epg);
return items;
}
public boolean isEmpty() {
return getName().isEmpty();
}

@ -68,7 +68,7 @@ public class LiveViewModel extends ViewModel {
public void getXml(Live item) {
execute(XML, () -> {
boolean result = false;
for (String url : item.getEpg().split(",")) if (EpgParser.start(item, url)) result = true;
for (String url : item.getEpgXml()) if (EpgParser.start(item, url)) result = true;
return result;
});
}

Loading…
Cancel
Save