MyJCOM2XMLTV/constants.py
2024-12-31 17:51:38 +09:00

54 lines
1.9 KiB
Python

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('<channel id="{}">'
'<display-name>{}</display-name>'
'<icon src="{}" />'
'</channel>\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, audio, subtitles):
self.programmes.append('<programme start="{} +0000" stop="{} +0000" channel="{}">'
'<title lang="ja">{}</title>'
'<desc lang="ja">{}</desc>'
'<category lang="ja">{}</category>'
'</programme>\n'.format(start, stop, channel, title, desc, category))
def create(self):
with open('data/epg.xml', mode='w', encoding='UTF-8') as epg:
epg.write('<?xml version="1.0" encoding="UTF-8"?>\n')
epg.write('<!DOCTYPE tv SYSTEM "xmltv.dtd">\n')
epg.write('<tv source-info-name="EPG Grabber">\n')
for channel in self.channels:
epg.write(channel)
for prg in self.programmes:
epg.write(prg)
epg.write('</tv>')
def _show_channels(self):
print(self.channels)
def _show_programmes(self):
print(self.programmes)