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 line and generate a link channel /index.m3u8 it should look like this #EXTM3U #EXTINF:-1, channel name channel /index.m3u8 and save it to a playlist.m3u file

#!/usr/bin/env python3 import re def get_list(file): with open(file) as f: lines = f.readlines() m3u8_list = [] link = '{}/index.m3u8' for i in range(len(lines)): if lines[i].startswith('title '): name = lines[i].replace('title ', '').replace('\n', '') id ='\d+', lines[i+2]).group(0) m3u8_list.append(name) m3u8_list.append(link.format(id)) return m3u8_list def write_data(file, data): with open(file, 'w') as f: for i in range(len(data)): if i % 2 == 0: f.write('#EXTINF:-1

Questions about programming?Chat with your personal AI assistant