m3u support catchup

release
FongMi 2 years ago
parent 6ff4a9238d
commit 8674fd7315
  1. 9
      app/src/main/java/com/fongmi/android/tv/api/LiveParser.java
  2. 8
      app/src/main/java/com/fongmi/android/tv/bean/Catchup.java
  3. 2
      app/src/main/java/com/fongmi/android/tv/bean/Channel.java

@ -1,7 +1,9 @@
package com.fongmi.android.tv.api;
import android.util.Base64;
import android.util.Log;
import com.fongmi.android.tv.bean.Catchup;
import com.fongmi.android.tv.bean.Channel;
import com.fongmi.android.tv.bean.ClearKey;
import com.fongmi.android.tv.bean.Drm;
@ -21,6 +23,8 @@ import java.util.regex.Pattern;
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 GROUP = Pattern.compile(".*group-title=\"(.?|.+?)\".*");
private static final Pattern LOGO = Pattern.compile(".*tvg-logo=\"(.?|.+?)\".*");
private static final Pattern NAME = Pattern.compile(".*,(.+?)$");
@ -62,15 +66,20 @@ public class LiveParser {
private static void m3u(Live live, String text) {
Setting setting = Setting.create();
Catchup catchup = Catchup.create();
Channel channel = Channel.create("");
for (String line : text.split("\n")) {
if (Thread.interrupted()) break;
if (setting.find(line)) {
setting.check(line);
} else if (line.startsWith("#EXTM3U")) {
catchup.setType(extract(line, CATCHUP));
catchup.setSource(extract(line, CATCHUP_SOURCE));
} else if (line.startsWith("#EXTINF:")) {
Group group = live.find(Group.create(extract(line, GROUP), live.isPass()));
channel = group.find(Channel.create(extract(line, NAME)));
channel.setLogo(extract(line, LOGO));
channel.setCatchup(catchup);
} else if (!line.startsWith("#") && line.contains("://")) {
String[] split = line.split("\\|");
if (split.length > 1) setting.headers(Arrays.copyOfRange(split, 1, split.length));

@ -27,6 +27,10 @@ public class Catchup {
return item;
}
public static Catchup create() {
return new Catchup();
}
public String getType() {
return TextUtils.isEmpty(type) ? "" : type;
}
@ -63,6 +67,10 @@ public class Catchup {
return url.contains(getRegex()) || Pattern.compile(getRegex()).matcher(url).find();
}
public boolean isEmpty() {
return getSource().isEmpty();
}
public String format(EpgData data) {
String result = getSource();
Matcher matcher = Pattern.compile("(\\$\\{[^}]*\\})").matcher(result);

@ -289,7 +289,7 @@ public class Channel {
public boolean hasCatchup() {
if (getCatchup() == null && getCurrent().contains("/PLTV/")) setCatchup(Catchup.PLTV());
if (getCatchup() != null && !getCatchup().getRegex().isEmpty()) return getCatchup().match(getCurrent());
return getCatchup() != null;
return getCatchup() != null && !getCatchup().isEmpty();
}
public String getLineText() {

Loading…
Cancel
Save