diff --git a/archivers/youtubedl_archiver.py b/archivers/youtubedl_archiver.py index 65c59be..83dbc78 100644 --- a/archivers/youtubedl_archiver.py +++ b/archivers/youtubedl_archiver.py @@ -89,11 +89,9 @@ class YoutubeDLArchiver(Archiver): os.remove(filename) - # TODO test YoutubeDL's date conventions for a variety of sources (Twitter, Youtube, etc) - # is the timestamp always in "user" time? - timestamp = datetime.datetime.fromtimestamp(info['timestamp']).replace(tzinfo=datetime.timezone(datetime.timedelta(hours=1))).astimezone(datetime.timezone.utc).isoformat() \ + 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').timestamp() \ + 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 diff --git a/auto_archive.py b/auto_archive.py index fba17f4..d54d2f1 100644 --- a/auto_archive.py +++ b/auto_archive.py @@ -36,14 +36,15 @@ def update_sheet(gw, row, result: archivers.ArchiveResult): batch_if_valid('screenshot', result.screenshot) batch_if_valid('hash', result.hash) - if type(result.timestamp) == int: - timestamp_string = datetime.datetime.fromtimestamp(result.timestamp).replace(tzinfo=datetime.timezone.utc).isoformat() - elif type(result.timestamp) == str: - timestamp_string = result.timestamp - else: - timestamp_string = result.timestamp.isoformat() + if result.timestamp is not None: + if type(result.timestamp) == int: + timestamp_string = datetime.datetime.fromtimestamp(result.timestamp).replace(tzinfo=datetime.timezone.utc).isoformat() + elif type(result.timestamp) == str: + timestamp_string = result.timestamp + else: + timestamp_string = result.timestamp.isoformat() - batch_if_valid('timestamp', timestamp_string) + batch_if_valid('timestamp', timestamp_string) gw.batch_set_cell(cell_updates)