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

def get_channel_name(line): name = line.split(' ')[1] return name def get_channel_id(line): channel_id = line.split('/')[2].split(' ')[0] return channel_id def main(): playlist = open('playlist.m3u', 'w') playlist.write('#EXTM3U') playlist.write('\n') channels = open('flussonic.conf').readlines() for i, line in enumerate(channels): if i == 0: name = get_channel_name(line) continue if line.startswith('stream'): id = get_channel_id(line) url = 'http://server-1.mitv-iptv.ru:80/' + id + '/index.m3u8' playlist.write('#EXTINF:0, ' + name + '\n') playlist.write(url + '\n') playlist.

Questions about programming?Chat with your personal AI assistant