Support multiple xml epg

pull/586/head
FongMi 1 year ago
parent 23915ed162
commit 0fe6afefae
  1. 12
      app/src/main/java/com/fongmi/android/tv/api/EpgParser.java
  2. 2
      app/src/main/java/com/fongmi/android/tv/api/LiveParser.java
  3. 6
      app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java

@ -27,10 +27,10 @@ import java.util.Set;
public class EpgParser {
public static boolean start(Live live) throws Exception {
if (!live.getEpg().contains("xml") && !live.getEpg().contains("gz")) return false;
File file = Path.epg(Uri.parse(live.getEpg()).getLastPathSegment());
if (shouldDownload(file)) Download.create(live.getEpg(), file).start();
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);
else readXml(live, file);
return true;
@ -86,7 +86,9 @@ public class EpgParser {
}
for (Group group : live.getGroups()) {
for (Channel channel : group.getChannel()) {
channel.setData(epgMap.get(channel.getTvgName()));
if (epgMap.containsKey(channel.getTvgName())) {
channel.setData(epgMap.get(channel.getTvgName()));
}
}
}
}

@ -28,9 +28,9 @@ public class LiveParser {
private static final Pattern CATCHUP_SOURCE = Pattern.compile(".*catchup-source=\"(.?|.+?)\".*");
private static final Pattern CATCHUP = Pattern.compile(".*catchup=\"(.?|.+?)\".*");
private static final Pattern TVG_URL = Pattern.compile(".*x-tvg-url=[\"']?([^\"'\\n,]+(?:,[^\"'\\n,]+)*)[\"']?");
private static final Pattern TVG_NAME = Pattern.compile(".*tvg-name=\"(.?|.+?)\".*");
private static final Pattern TVG_LOGO = Pattern.compile(".*tvg-logo=\"(.?|.+?)\".*");
private static final Pattern TVG_URL = Pattern.compile(".*x-tvg-url=\"(.?|.+?)\".*");
private static final Pattern GROUP = Pattern.compile(".*group-title=\"(.?|.+?)\".*");
private static final Pattern NAME = Pattern.compile(".*,(.+?)$");
private static final Pattern M3U = Pattern.compile("#EXTM3U|#EXTINF");

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

Loading…
Cancel
Save