add notification script to detect new Zander episodes (run via cron). can later easily be extended to automatic download of new episodes

This commit is contained in:
fordprefect
2022-01-13 17:59:04 +01:00
parent 965a099e60
commit 66bd0bbc9a

26
zanderdetect.py Normal file
View File

@@ -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