commit c9414538180040bf3926f92492754a7c1d6303b6 Author: Firepup Sixfifty Date: Wed May 1 08:17:20 2024 -0500 Inital Commit diff --git a/news.py b/news.py new file mode 100755 index 0000000..a684bf5 --- /dev/null +++ b/news.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +import xml.etree.ElementTree as ET +from urllib.request import urlretrieve as curl + +doc = ET.parse(curl("https://micronews.debian.org/feeds/atom.xml")[0]).getroot() +drops = {} +drops[0] = doc[5][0].text +while any(len(drops[i]) > 77 for i in drops.keys()): + ind = -1 + g = False + for j in drops.keys(): + ind += 1 + if len(drops[j]) > 77: + if len(drops[j].split()) > 1: + g = True + break + else: + drops[j] = drops[j][:74] + "..." + if not g: + break + if drops.get(ind+1,None) == None: + drops[ind+1] = "" + drops[ind+1] = f"{drops[ind].split()[-1]} {drops[ind+1]}".strip() + drops[ind] = " ".join(drops[ind].split()[:-1]) +title = "\n * ".join(drops.values()).lstrip("\n") +link = doc[5][1].attrib["href"] +print( + f""" * {title} + + {link}""" +)