Евгений Добролюбов

All generations.

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))

Python
View
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 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

def playlist(file): with open(file, 'r') as f: lines = f.readlines() for line in lines: if line.startswith('title'): title = line.split('=')[1].strip() if line.startswith('playlist') and 'm3u8' in line: id = line.split('/')[2].strip() url = 'http://server-1.mitv-iptv.ru:80/{}/index.m3u8'.format(id) print('#EXTINF:-1, {}'.format(title)) print(url) playlist('flussonic.conf')

Python
View
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 playlist(name, id): pass playlist(name, id)

Python
View
generate functionWed, 15 Feb 2023

создания плейлиста m3u со вложенных файлов в папке linux

#!/usr/bin/env python3 import os import sys from os import listdir from os.path import isdir, isfile, join from os import walk from re import search #print("sys.argv[0] =", sys.argv[0]) #print("sys.argv[1] =", sys.argv[1]) path = sys.argv[1] def get_files(path): files = [f for f in listdir(path) if isfile(join(path, f)) and (search('mp3', f, flags=0) or search('m4a', f, flags=0) or search('wav', f, flags=0))] for file in files: print(file) def print_playlist(): print("#EXTM3U") for (path, dirs, files) in walk(sys.argv[1]): for file in files: if (search('mp3', file, flags=0) or search('m4

Python
View
generate functionWed, 15 Feb 2023

создания плейлиста m3u со вложенных файлов в папке linux формат файлов mp4

import os import sys def get_filenames(path): filenames = [] for root, dirs, files in os.walk(path): for file in files: filenames.append(os.path.join(root, file)) return filenames def save_to_m3u(filenames, path): with open(path, 'w') as f: for filename in filenames: f.write(filename + '\n') return path if __name__ == '__main__': path = sys.argv[1] filenames = get_filenames(path) save_to_m3u(filenames, 'playlist.m3u')

Python
View
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 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

with open("flussonic.conf") as f: lines = f.readlines() for line in lines: if "title" in line: print("#EXTM3U") title = line.split(" ")[1].strip() print("#EXTINF:-1," + title) print("http://server-1.mitv-iptv.ru:80/" + line.split("/")[1].split(" ")[0] + "/index.m3u8")

Python
View
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 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

#!/usr/bin/env python3 import re def get_list(file): with open(file) as f: lines = f.readlines() m3u8_list = [] link = 'http://server-1.mitv-iptv.ru:80/{}/index.m3u8' for i in range(len(lines)): if lines[i].startswith('title '): name = lines[i].replace('title ', '').replace('\n', '') id = re.search(r'\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

Python
View
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 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 os def main(): file = open('flussonic.conf', 'r') file = file.readlines() for i in file: if i[0] == 't': title = i if i[0] == 'u': id = i title = title[7:-2] id = id[12:-1] playlist = '#EXTM3U\n#EXTINF:-1,' + title + '\nhttp://server-1.mitv-iptv.ru:80/' + id + '/index.m3u8' playlist_file = open('playlist.m3u', 'w') playlist_file.write(playlist) playlist_file.close() if __name__ == '__main__': main()

Python
View
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.

Python
View

Questions about programming?Chat with your personal AI assistant