mirror of https://github.com/Free-TV/IPTV
Merge pull request #309 from glotovpa/master
Add creating playlists by country in the folder "playlists"pull/313/head
commit
221c965bfc
|
@ -27,14 +27,22 @@ 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}')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
dir_playlists = 'playlists'
|
||||||
|
if not (os.path.isdir(dir_playlists)):
|
||||||
|
os.mkdir(dir_playlists)
|
||||||
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
||||||
|
head_playlist = '#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"'
|
||||||
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")
|
||||||
for filename in sorted(os.listdir(".")):
|
for filename in sorted(os.listdir(".")):
|
||||||
if filename == "README.md" or not filename.endswith(".md"):
|
if filename == "README.md" or not filename.endswith(".md"):
|
||||||
continue
|
continue
|
||||||
with open(filename, encoding='utf-8') as markup_file:
|
with open(filename, encoding='utf-8') as markup_file:
|
||||||
|
file_country = "../" + dir_playlists + "\playlist_" + filename[:-3:] + ".m3u8"
|
||||||
|
playlist_country = open(file_country, "w", encoding='utf-8')
|
||||||
|
playlist_country.write(head_playlist)
|
||||||
group = filename.replace(".md", "").title()
|
group = filename.replace(".md", "").title()
|
||||||
print(f"Generating {group}")
|
print(f"Generating {group}")
|
||||||
for line in markup_file:
|
for line in markup_file:
|
||||||
|
@ -44,6 +52,8 @@ def 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)
|
||||||
|
print(channel.to_m3u_line(), file=playlist_country)
|
||||||
|
playlist_country.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue