Convert start/end times to Epoch timestamps.

This commit is contained in:
Yuuki 2025-01-02 21:58:11 +09:00
parent 79c63feed0
commit 1ff00c7405
2 changed files with 7 additions and 5 deletions

View file

@ -31,8 +31,8 @@ class XMLTV:
def add_programme(self, channel, title, desc, start, stop, category, attr, icon): def add_programme(self, channel, title, desc, start, stop, category, attr, icon):
# TODO: add `duo` attribute (bilingual) # TODO: add `duo` attribute (bilingual)
programme = '<programme start="{} +0900" stop="{} +0900" channel="{}">'.format(start, stop, channel) programme = '<programme start="{} +0000" stop="{} +0000" channel="{}">'.format(start, stop, channel)
programme += '<title>{}</title>'.format(title) programme += '<title lang="ja">{}</title>'.format(title)
programme += '<desc>{}</desc>'.format(desc) programme += '<desc>{}</desc>'.format(desc)
programme += '<category lang="ja">{}</category>'.format(category) programme += '<category lang="ja">{}</category>'.format(category)
if icon: programme += '<icon src="{}" />'.format(icon) if icon: programme += '<icon src="{}" />'.format(icon)

8
run.py
View file

@ -73,13 +73,15 @@ for x in range(0, 7):
channel = chid[0:chid.rfind('_')] channel = chid[0:chid.rfind('_')]
title = epg_data['title'] title = epg_data['title']
comment = epg_data['commentary'] comment = epg_data['commentary']
start = epg_data['programStart'] start = str(epg_data['programStart'])
end = epg_data['programEnd'] 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()
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()
gen = genre(epg_data['sortGenre']) gen = genre(epg_data['sortGenre'])
attr = epg_data['attr'] 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 icon = 'https://tvguide.myjcom.jp{}'.format(epg_data['imgPath']) if int(epg_data['hasImage']) == 1 and epg_data['imgPath'] else None
guide.add_programme(channel, title, comment, start, end, gen, attr, icon) guide.add_programme(channel, title, comment, str(start)[:-2], str(end)[:-2], gen, attr, icon)
print('Added EPG info for', title) print('Added EPG info for', title)