from enum import Enum class CITY(Enum): # TODO: Add all these cities: https://c.myjcom.jp/shared/common/js/region/data/cityMaster.js?_=1735632747105 # TODO: Change these to cities' names KYUSHU1 = 35 KYUSHU2 = 36 KYUSHU3 = 54 MIYAGI1 = 52 OSAKA1 = 40 OSAKA2 = 46 TOKYO1 = 19 TOKYO2 = 100 TOKYO3 = 222 class XMLTV: def __init__(self): self.channels = [] self.programmes = [] def add_channel(self, channel, display_name, icon): self.channels.append('' '{}' '' '\n'.format(channel, display_name, icon)) def write_channels(self): for c in self.channels: open('data/channels.xml', mode='a', encoding='UTF-8').write(c) def add_programme(self, channel, title, desc, start, stop, category, attr, icon): programme = ''.format(start, stop, channel) programme += '{}'.format(title) programme += '{}'.format(desc) programme += '{}'.format(category) if icon: programme += ''.format(icon) if 'stereo' in attr: programme += '' if 'mono' in attr: programme += '' if 'hd' in attr: programme += '' if 'cp1' in attr: programme += '' programme += '\n' self.programmes.append(programme) def create(self): with open('data/epg.xml', mode='w', encoding='UTF-8') as epg: epg.write('\n') epg.write('\n') epg.write('\n') for channel in self.channels: epg.write(f'{channel}\n') for prg in self.programmes: epg.write(prg) epg.write('') def _show_channels(self): print(self.channels) def _show_programmes(self): print(self.programmes)