mirror of
https://github.com/Kunsi/scheduled-plugin-pretalx-broadcast-tools.git
synced 2024-11-22 10:01:06 +00:00
service: fix missing timezone handling for start_str generation
This commit is contained in:
parent
d7e0fc8a47
commit
f22ab686ab
1 changed files with 7 additions and 8 deletions
15
service
15
service
|
@ -19,14 +19,13 @@ def log(msg):
|
||||||
def idle(seconds, event_start, event_tz):
|
def idle(seconds, event_start, event_tz):
|
||||||
end = time.time() + seconds
|
end = time.time() + seconds
|
||||||
log("sleeping for {} seconds".format(seconds))
|
log("sleeping for {} seconds".format(seconds))
|
||||||
timezone = pytz.timezone(event_tz)
|
|
||||||
while time.time() < end:
|
while time.time() < end:
|
||||||
send_data = {
|
send_data = {
|
||||||
'day': '??',
|
'day': '??',
|
||||||
'time': time.time()
|
'time': time.time()
|
||||||
}
|
}
|
||||||
if event_start is not None:
|
if event_start is not None:
|
||||||
event_now = datetime.now(timezone)
|
event_now = datetime.now(event_tz)
|
||||||
utc_now = datetime.now(pytz.utc)
|
utc_now = datetime.now(pytz.utc)
|
||||||
|
|
||||||
utc_offset = (event_now - utc_now).total_seconds()
|
utc_offset = (event_now - utc_now).total_seconds()
|
||||||
|
@ -55,7 +54,7 @@ def main():
|
||||||
event_info = None
|
event_info = None
|
||||||
event_start = None
|
event_start = None
|
||||||
schedule = None
|
schedule = None
|
||||||
event_tz = 'UTC'
|
event_tz = pytz.utc
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event_url = config["event_url"]
|
event_url = config["event_url"]
|
||||||
|
@ -84,6 +83,10 @@ def main():
|
||||||
node.write_json("event.json", event_info)
|
node.write_json("event.json", event_info)
|
||||||
log("updated event info json")
|
log("updated event info json")
|
||||||
|
|
||||||
|
if event_info is not None:
|
||||||
|
event_start = datetime.strptime(event_info["start"], "%Y-%m-%d")
|
||||||
|
event_tz = pytz.timezone(event_info['timezone'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = get(
|
r = get(
|
||||||
event_url + "p/broadcast-tools/schedule.json",
|
event_url + "p/broadcast-tools/schedule.json",
|
||||||
|
@ -97,14 +100,10 @@ def main():
|
||||||
else:
|
else:
|
||||||
schedule = r.json()
|
schedule = r.json()
|
||||||
for talk in schedule['talks']:
|
for talk in schedule['talks']:
|
||||||
talk['start_str'] = datetime.fromtimestamp(talk['start_ts']).strftime('%H:%M')
|
talk['start_str'] = datetime.fromtimestamp(talk['start_ts']).astimezone(event_tz).strftime('%H:%M')
|
||||||
node.write_json("schedule.json", schedule)
|
node.write_json("schedule.json", schedule)
|
||||||
log("updated schedule json")
|
log("updated schedule json")
|
||||||
|
|
||||||
if event_info is not None:
|
|
||||||
event_start = datetime.strptime(event_info["start"], "%Y-%m-%d")
|
|
||||||
event_tz = event_info['timezone']
|
|
||||||
|
|
||||||
idle(30, event_start, event_tz)
|
idle(30, event_start, event_tz)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue