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",
|
||||
)
|
||||
|
||||
class Channel():
|
||||
|
||||
class Channel:
|
||||
def __init__(self, group, md_line):
|
||||
self.group = group
|
||||
md_line = md_line.strip()
|
||||
try:
|
||||
(before, number, name, url, logo, epg, after) = md_line.split("|")
|
||||
except ValueError:
|
||||
(before, number, name, url, logo, after) = md_line.split("|")
|
||||
epg = None
|
||||
self.number = number.strip()
|
||||
self.name = name.strip()
|
||||
self.url = url.strip()
|
||||
parts = md_line.split("|")
|
||||
self.number = parts[1].strip()
|
||||
self.name = parts[2].strip()
|
||||
self.url = parts[3].strip()
|
||||
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.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):
|
||||
if self.epg is None:
|
||||
|
@ -279,7 +278,7 @@ class Channel():
|
|||
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}')
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
||||
print(f'#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"', file=playlist)
|
||||
os.chdir("lists")
|
||||
|
@ -296,3 +295,6 @@ if __name__ == "__main__":
|
|||
continue
|
||||
channel = Channel(group, line)
|
||||
print(channel.to_m3u_line(), file=playlist)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue