diff --git a/make_playlist.py b/make_playlist.py index a07d26d..daa7aa5 100755 --- a/make_playlist.py +++ b/make_playlist.py @@ -27,14 +27,22 @@ 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}') + 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: + head_playlist = '#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"' print(f'#EXTM3U x-tvg-url="{",".join(EPG_LIST)}"', file=playlist) os.chdir("lists") for filename in sorted(os.listdir(".")): if filename == "README.md" or not filename.endswith(".md"): continue 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() print(f"Generating {group}") for line in markup_file: @@ -44,6 +52,8 @@ def main(): continue channel = Channel(group, line) print(channel.to_m3u_line(), file=playlist) + print(channel.to_m3u_line(), file=playlist_country) + playlist_country.close() if __name__ == "__main__": main()