diff --git a/constants.py b/constants.py index a37dda3..2544aed 100644 --- a/constants.py +++ b/constants.py @@ -1,32 +1,17 @@ from enum import Enum class CITY(Enum): - TOKYO1 = 12 - TOKYO2 = 221 + # 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 - OSAKA1 = 28 - OSAKA2 = 40 - OSAKA3 = 42 - OSAKA4 = 44 - OSAKA5 = 30 - KYOTO = 46 - HYOGO = 106 - WAKAYAMA = 25 - YAMAGUCHI = 39 - FUKUOKA = 37 - KUMAMOTO = 227 - HOKKAIDO = 1 - MIYAGI = 52 - GUNMA = 13 - IBARAKI = 2 - CHIBA1 = 3 - CHIBA2 = 217 - CHIBA3 = 219 - CHIBA4 = 300 - KANAGAWA1 = 101 - KANAGAWA2 = 201 - SAITAMA1 = 3 - SAITAMA2 = 214 class XMLTV: diff --git a/run.py b/run.py index 61c8b7d..6a014fa 100644 --- a/run.py +++ b/run.py @@ -43,7 +43,7 @@ def request_url() -> str: if not file_exists('data/channels.xml'): - c_area = CITY.OSAKA2.value + c_area = CITY.OSAKA1.value c_adult = 'true' for c_type in [2, 3, 5, 120]: # GR / BS / BS4K / CS @@ -77,8 +77,12 @@ for x in range(0, 7): channel = chid[0:chid.rfind('_')] title = fix(epg_data['title']) comment = fix(epg_data['commentary']) - start = datetime.fromtimestamp(datetime.strptime(epg_data['programStart'], '%Y%m%d%H%M%S').timestamp() - 32400).strftime('%Y%m%d%H%M%S') - end = datetime.fromtimestamp(datetime.strptime(epg_data['programEnd'], '%Y%m%d%H%M%S').timestamp() - 32400).strftime('%Y%m%d%H%M%S') + start = str(epg_data['programStart']) + start = datetime(int(start[0:4]), int(start[4:6]), int(start[6:8]), int(start[8:10]), int(start[10:12]), int(start[12:14])).timestamp() - 32400 + start = datetime.fromtimestamp(start).strftime('%Y%m%d%H%M%S') + end = str(epg_data['programEnd']) + end = datetime(int(end[0:4]), int(end[4:6]), int(end[6:8]), int(end[8:10]), int(end[10:12]), int(end[12:14])).timestamp() - 32400 + end = datetime.fromtimestamp(end).strftime('%Y%m%d%H%M%S') gen = genre(epg_data['sortGenre']) attr = epg_data['attr'] icon = 'https://tvguide.myjcom.jp{}'.format(epg_data['imgPath']) if int(epg_data['hasImage']) == 1 and epg_data['imgPath'] else None