import feedparser import os from icalendar import Calendar import datetime from requests import get import urllib import json import pypandoc import time ics = get("https://varia.zone/events.ics").text gcal = Calendar.from_ical(ics) now = datetime.datetime.now() while True: #os.system("toilet --gay -w 125 -W --filter border:gay \ \ \ \ \ VARIA\ \ \ \ \ ") os.system("./venv/bin/python3 tools/ascii-art-but-with-unicode/repeated_sinus_amplitude_variation.py | lolcat -a -d 1") print("") time.sleep(1) os.system("./venv/bin/python3 tools/ascii-art-but-with-unicode/multi_column_page.py | lolcat -a -d 1") print("") time.sleep(10) for c in gcal.walk(): if c.name == "VEVENT": date = c.get("dtstart").dt title = c.get("summary") if date > now: # An attempt to keep TeleVex running throughout the night # (even if the Multifeeder/server is not available) 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: # 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: 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']) # Send the event to the terminal· # Title os.system(f"toilet -f big --gay -w 125 '{ title }'") print("") time.sleep(1) # Date print(date.strftime("%A %d %B %Y (%H:%M:%S)")) 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") print("") time.sleep(3)