Skip to content

Commit

Permalink
Prevent Atom updated dates overriding published
Browse files Browse the repository at this point in the history
  • Loading branch information
romlok committed Feb 5, 2018
1 parent b07d7c6 commit a6ad7fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions podcastparser.py
Expand Up @@ -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
Expand Down Expand Up @@ -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))


Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit a6ad7fd

Please sign in to comment.