From 5a28106714a9732574665764452be40c54f02e0f Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 27 Jan 2019 18:17:58 +0100 Subject: [PATCH] feed: date from txdate= --- feed | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/feed b/feed index 05870e0..fe14aee 100755 --- a/feed +++ b/feed @@ -188,7 +188,9 @@ def get_audio_from_description(text): except ValueError: logging.warning('could not parse txdate %s', metadata['txdate']) del metadata['txdate'] - a = Audio(unquote(url), metadata.get('durata', None)) + a = Audio(unquote(url), + duration=metadata.get('durata', None), + date=metadata.get('txdate', None)) if 'txdate' in metadata and 'replica' in metadata: if metadata['replica'].endswith('g'): @@ -214,7 +216,6 @@ def get_audio_from_dir(dirpath): def get_item_date(el): - # TODO: pick from txdate= el_date = el.find('pubdate') if el_date is not None: return datetime.datetime.strptime( @@ -234,7 +235,8 @@ def get_urls(tree): except Exception as exc: logging.info('error getting duration for `%s`' % title) continue - audio.date = get_item_date(it) + if audio.date is None: + audio.date = get_item_date(it) yield audio