Browse Source

tweaking the screen script to avoid errors in the event descriptions

master
televex 4 years ago
parent
commit
f163337313
  1. 32
      screen/televex.py

32
screen/televex.py

@ -19,7 +19,6 @@ now = datetime.datetime.now()
while True:
#os.system("toilet --gay -w 125 -W --filter border:gay \ \ \ \ \ VARIA\ \ \ \ \ ")
os.system(f"{ PYTHON } tools/ascii-art-but-with-unicode/repeated_sinus_amplitude_variation.py | lolcat -a -d 1")
print("")
time.sleep(1)
@ -29,6 +28,9 @@ while True:
print("")
time.sleep(10)
# Avoid double posts
used = []
for c in gcal.walk():
if c.name == "VEVENT":
@ -40,30 +42,39 @@ while True:
# An attempt to keep TeleVex running throughout the night
# (even if the Multifeeder/server is not available)
# --- works ---
try:
url = 'https://multi.vvvvvvaria.org/API/latest/25'
response = urllib.request.urlopen(url).read()
multifeeder = json.loads(response)
except:
multifeeder = []
os.system("toilet -f script -w 125 --gay Zzz... the server sleeps.")
for post in multifeeder:
if post["summary"] not in used:
# Clean up the title of the RSS & Calendar
title_check = title.lower().strip().replace('\n','')
rss_title_check = post["title"].lower().strip().replace('\n','')
if title_check == rss_title_check:
# add this post to the "used" list above
used.append(post["summary"])
os.system("toilet --gay -w 125 -W --filter border:gay \ \ \ COMING UP\ \ \ \ ")
print("")
time.sleep(1)
description = pypandoc.convert_text(post["summary"], 'plain', format='html',extra_args=['--columns=64'])
# Write description to a tmp file
with open("description.tmp","w") as tmp:
tmp.write(description)
# Send the event to the terminal·
# Title
@ -72,20 +83,13 @@ while True:
time.sleep(1)
# Date
print(date.strftime("%A %d %B %Y (%H:%M:%S)"))
event_date = date.strftime("%A %d %B %Y (%H:%M:%S)")
os.system(f"echo '{ event_date }' | lolcat -a -d 1")
print("")
time.sleep(1)
# Description
lines = [line for line in description.split('\n')]
for line in lines:
# HACKY!!!
line = line.replace('\n', '')
#line = line.replace('(', '(')
#line = line.replace(')', ')')
#line = line.replace(';', '\;')
#line = line.replace('"', '\"')
#line = line.replace("'", "\'")
os.system(f"echo '{ line }' | lolcat -a -d 1")
os.system("cat description.tmp | lolcat -a -d 1")
print("")
time.sleep(3)
time.sleep(10)

Loading…
Cancel
Save