Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xml.etree.ElementTree as ET
- with open('channel,xml', 'r', encoding='utf-8') as f:
- xml = f.read()
- root = ET.fromstring(xml)
- channel = {}
- with open('tmp.txt', 'a', encoding='utf-8') as f:
- for child in root[0]:
- tmp_dict = {}
- for child1 in child:
- tmp_dict[child1.tag] = child1.text
- channel[tmp_dict['channelId']] = tmp_dict
- tmp_guid = ''
- with open('old._tvguid.txt', 'r', encoding='utf-8') as f:
- try:
- for i in f.readlines():
- if i.startswith('#EXT-INETRA-CHANNEL-INF:'):
- channel_id = i.split(' ')[1].split('=')[-1].strip()
- tmp_guid += i
- continue
- elif i.startswith('#EXTINF'):
- m_text = i.split(',')
- url = '/'.join(['http://nsotelecom.ru/wp-content/uploads/2023/icon', channel[channel_id]['logoURL'].split('/')[-1]])
- tmp_guid += f'{m_text[0]} tvg-logo="{url}", {m_text[1].strip()}\n'
- else:
- tmp_guid += i
- except KeyError:
- tmp_guid += i
- with open('nso-telecom.m3u8', 'a', encoding='utf-8') as f:
- f.write(tmp_guid)
Add Comment
Please, Sign In to add comment