generate functionWed, 15 Feb 2023

write me a script in python to generate a playlist in the folder there is a file flussonic.conf take the name of the channel from the title line, then take the channel id from this stream line and generate a link http://server-1.mitv-iptv.ru:80/id channel /index.m3u8 it should look like this #EXTM3U #EXTINF:-1, channel name http://server-1.mitv-iptv.ru:80/id channel /index.m3u8 and save it to a playlist.m3u file

import re with open("flussonic.conf") as file: for line in file: title = re.search(r'title (.*)', line) if title: channel_name = title.group(1).strip() stream = re.search(r'stream (.*)', line) if stream: channel_id = stream.group(1).strip() with open("playlist.m3u", "a") as playlist: playlist.write("#EXTM3U\n") playlist.write("#EXTINF:-1,{}\n".format(channel_name)) playlist.write("http://server-1.mitv-iptv.ru:80/{}/index.m3u8\n".format(channel_id))

Questions about programming?Chat with your personal AI assistant