Permalink
Browse files

Prevent Atom updated dates overriding published

  • Loading branch information...
romlok committed Feb 5, 2018
1 parent b07d7c6 commit a6ad7fdc7a438ed6f6f2c81819dfb4e8a303107c
Showing with 5 additions and 2 deletions.
  1. +5 −2 podcastparser.py
@@ -70,9 +70,10 @@ def mktime_tz(data):
class Target(object):
WANT_TEXT = False
def __init__(self, key=None, filter_func=lambda x: x.strip()):
def __init__(self, key=None, filter_func=lambda x: x.strip(), overwrite=True):
self.key = key
self.filter_func = filter_func
self.overwrite = overwrite
def start(self, handler, attrs):
pass
@@ -129,6 +130,8 @@ class EpisodeAttr(Target):
WANT_TEXT = True
def end(self, handler, text):
if not self.overwrite and handler.get_episode_attr(self.key):
return
handler.set_episode_attr(self.key, self.filter_func(text))
@@ -620,7 +623,7 @@ def parse_pubdate(text):
'atom:feed/atom:entry/atom:content': AtomContent(),
'atom:feed/atom:entry/content:encoded': EpisodeAttr('description_html'),
'atom:feed/atom:entry/atom:published': EpisodeAttr('published', parse_pubdate),
'atom:feed/atom:entry/atom:updated': EpisodeAttr('published', parse_pubdate),
'atom:feed/atom:entry/atom:updated': EpisodeAttr('published', parse_pubdate, overwrite=False),
'atom:feed/atom:entry/media:group/media:description': EpisodeAttr('description', squash_whitespace),
'atom:feed/atom:entry/psc:chapters': PodloveChapters(),
'atom:feed/atom:entry/psc:chapters/psc:chapter': PodloveChapter(),

0 comments on commit a6ad7fd

Please sign in to comment.