From 875ec09d4e8460aceed816e27d7ed35c05784117 Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 14 Jun 2020 16:38:16 +0200 Subject: [PATCH] stub out tombstones/deleted-entry support --- app/common/common.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/common/common.py b/app/common/common.py index 5596521..90e7bb3 100644 --- a/app/common/common.py +++ b/app/common/common.py @@ -38,10 +38,16 @@ def parse_xml(xmldata): ns = { 'atom':"http://www.w3.org/2005/Atom", 'yt': "http://www.youtube.com/xml/schemas/2015", - 'media':"http://search.yahoo.com/mrss/" + 'media':"http://search.yahoo.com/mrss/", + 'at': "http://purl.org/atompub/tombstones/1.0", } feed = ElementTree.fromstring(xmldata) + if feed.find('at:deleted-entry',ns): + author = feed.find('at:deleted-entry/at:by/name',ns).text + ref = feed.find('at:deleted-entry',ns).get('ref') + (_, _, video_id) = ref.rpartition(':') + return None, None, [] title = feed.find('atom:title',ns).text author = feed.find('atom:author/atom:name',ns).text \ if feed.find('atom:author',ns) else None @@ -65,6 +71,8 @@ def update_channel(db, xmldata): # Note: websub does not return global author, hence taking from first video title, _, videos = parse_xml(xmldata) + # TODO: if not title: delete from videos (this should only be implemented after webhook hmac validation!) + c = db.cursor() for i, video in enumerate(videos): now = datetime.now(timezone.utc) -- 2.39.3