mirror of https://github.com/Free-TV/IPTV
commit
0a101fb123
|
@ -255,23 +255,22 @@ EPG_LIST = ( "https://iptv-org.github.io/epg/guides/af.xml",
|
||||||
"https://iptv-org.github.io/epg/guides/ax.xml",
|
"https://iptv-org.github.io/epg/guides/ax.xml",
|
||||||
)
|
)
|
||||||
|
|
||||||
class Channel():
|
|
||||||
|
|
||||||
|
class Channel:
|
||||||
def __init__(self, group, md_line):
|
def __init__(self, group, md_line):
|
||||||
self.group = group
|
self.group = group
|
||||||
md_line = md_line.strip()
|
md_line = md_line.strip()
|
||||||
try:
|
parts = md_line.split("|")
|
||||||
(before, number, name, url, logo, epg, after) = md_line.split("|")
|
self.number = parts[1].strip()
|
||||||
except ValueError:
|
self.name = parts[2].strip()
|
||||||
(before, number, name, url, logo, after) = md_line.split("|")
|
self.url = parts[3].strip()
|
||||||
epg = None
|
|
||||||
self.number = number.strip()
|
|
||||||
self.name = name.strip()
|
|
||||||
self.url = url.strip()
|
|
||||||
self.url = self.url[self.url.find("(")+1:self.url.rfind(")")]
|
self.url = self.url[self.url.find("(")+1:self.url.rfind(")")]
|
||||||
self.logo = logo.strip()
|
self.logo = parts[4].strip()
|
||||||
self.logo = self.logo[self.logo.find('src="')+5:self.logo.rfind('"')]
|
self.logo = self.logo[self.logo.find('src="')+5:self.logo.rfind('"')]
|
||||||
self.epg = epg.strip() if epg else None
|
if len(parts) > 6:
|
||||||
|
self.epg = parts[5].strip()
|
||||||
|
else:
|
||||||
|
self.epg = None
|
||||||
|
|
||||||
def to_m3u_line(self):
|
def to_m3u_line(self):
|
||||||
if self.epg is None:
|
if self.epg is None:
|
||||||
|
@ -279,7 +278,7 @@ class Channel():
|
||||||
else:
|
else:
|
||||||
return (f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}" tvg-id="{self.epg}" group-title="{self.group}",{self.name}\n{self.url}')
|
return (f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}" tvg-id="{self.epg}" group-title="{self.group}",{self.name}\n{self.url}')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
||||||
print(f'#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"', file=playlist)
|
print(f'#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"', file=playlist)
|
||||||
os.chdir("lists")
|
os.chdir("lists")
|
||||||
|
@ -296,3 +295,6 @@ if __name__ == "__main__":
|
||||||
continue
|
continue
|
||||||
channel = Channel(group, line)
|
channel = Channel(group, line)
|
||||||
print(channel.to_m3u_line(), file=playlist)
|
print(channel.to_m3u_line(), file=playlist)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue