From 2ac08a34f633800c073f82bd3f5eedc491456d8d Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:45:02 +0200 Subject: [PATCH] ydl timestamp bug fix --- archivers/youtubedl_archiver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archivers/youtubedl_archiver.py b/archivers/youtubedl_archiver.py index be3477d..7990131 100644 --- a/archivers/youtubedl_archiver.py +++ b/archivers/youtubedl_archiver.py @@ -106,11 +106,11 @@ class YoutubeDLArchiver(Archiver): os.remove(filename) - timestamp = datetime.datetime.utcfromtimestamp(info['timestamp']).replace(tzinfo=datetime.timezone.utc).isoformat() \ - if 'timestamp' in info else \ - datetime.datetime.strptime(info['upload_date'], '%Y%m%d').replace(tzinfo=datetime.timezone.utc) \ - if 'upload_date' in info and info['upload_date'] is not None else \ - None + timestamp = None + if 'timestamp' in info and info['timestamp'] is not None: + timestamp = datetime.datetime.utcfromtimestamp(info['timestamp']).replace(tzinfo=datetime.timezone.utc).isoformat() + elif 'upload_date' in info and info['upload_date'] is not None: + timestamp = datetime.datetime.strptime(info['upload_date'], '%Y%m%d').replace(tzinfo=datetime.timezone.utc) return ArchiveResult(status=status, cdn_url=cdn_url, thumbnail=key_thumb, thumbnail_index=thumb_index, duration=duration, title=info['title'] if 'title' in info else None, timestamp=timestamp, hash=hash, screenshot=screenshot)