diff --git a/zanderdetect.py b/zanderdetect.py new file mode 100644 index 0000000..ee80e7d --- /dev/null +++ b/zanderdetect.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +from defusedxml.ElementTree import fromstring +import urllib.request + +url = "https://www1.wdr.de/mediathek/audio/zeitzeichen/zeitzeichen-podcast-100.podcast" + +def findZander(today): + for n, item in enumerate(today): + if item.tag.find("title") >= 0: + title = today[n].text + if item.tag.find("author") >= 0: + author = today[n].text + if item.tag.find("enclosure") >= 0: + podcasturl = today[n].attrib["url"] + + if author.find("Zander") > 0: + print(f"ZanderAlert: {title}\nDownload-URL: {podcasturl}") + +with urllib.request.urlopen(url) as response: + feed = fromstring(response.read())[0] + +for i in feed: + if i.tag == "item": + findZander(i) + break