diff --git a/app/src/main/java/com/fongmi/android/tv/api/LiveParser.java b/app/src/main/java/com/fongmi/android/tv/api/LiveParser.java index 25b35bc27..5f4293f13 100644 --- a/app/src/main/java/com/fongmi/android/tv/api/LiveParser.java +++ b/app/src/main/java/com/fongmi/android/tv/api/LiveParser.java @@ -26,8 +26,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_NAME = Pattern.compile(".*tvg-name=\"(.?|.+?)\".*"); + private static final Pattern TVG_LOGO = Pattern.compile(".*tvg-logo=\"(.?|.+?)\".*"); 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(".*,(.+?)$"); private static String extract(String line, Pattern pattern) { @@ -79,7 +80,8 @@ public class LiveParser { } 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.setTvgName(extract(line, TVG_NAME)); + channel.setLogo(extract(line, TVG_LOGO)); channel.setCatchup(catchup); } else if (!line.startsWith("#") && line.contains("://")) { String[] split = line.split("\\|"); diff --git a/app/src/main/java/com/fongmi/android/tv/bean/Channel.java b/app/src/main/java/com/fongmi/android/tv/bean/Channel.java index 6eaee5cb7..646b3ea0f 100644 --- a/app/src/main/java/com/fongmi/android/tv/bean/Channel.java +++ b/app/src/main/java/com/fongmi/android/tv/bean/Channel.java @@ -23,6 +23,8 @@ public class Channel { @SerializedName("urls") private List urls; + @SerializedName("tvgName") + private String tvgName; @SerializedName("number") private String number; @SerializedName("logo") @@ -88,6 +90,14 @@ public class Channel { this.name = name; } + public String getTvgName() { + return TextUtils.isEmpty(tvgName) ? getName() : tvgName; + } + + public void setTvgName(String tvgName) { + this.tvgName = tvgName; + } + public List getUrls() { return urls = urls == null ? new ArrayList<>() : urls; } @@ -326,8 +336,8 @@ public class Channel { if (!live.getCatchup().isEmpty() && getCatchup().isEmpty()) setCatchup(live.getCatchup()); if (live.getReferer().length() > 0 && getReferer().isEmpty()) setReferer(live.getReferer()); if (live.getPlayerType() != -1 && getPlayerType() == -1) setPlayerType(live.getPlayerType()); - if (!getEpg().startsWith("http")) setEpg(live.getEpg().replace("{name}", getName()).replace("{epg}", getEpg())); - if (!getLogo().startsWith("http")) setLogo(live.getLogo().replace("{name}", getName()).replace("{logo}", getLogo())); + if (!getEpg().startsWith("http")) setEpg(live.getEpg().replace("{name}", getTvgName()).replace("{epg}", getEpg())); + if (!getLogo().startsWith("http")) setLogo(live.getLogo().replace("{name}", getTvgName()).replace("{logo}", getLogo())); } public void setLine(String line) { @@ -346,6 +356,7 @@ public class Channel { setPlayerType(item.getPlayerType()); setCatchup(item.getCatchup()); setReferer(item.getReferer()); + setTvgName(item.getTvgName()); setHeader(item.getHeader()); setNumber(item.getNumber()); setOrigin(item.getOrigin());