Fix issue with timestamps being convereted to user format

pull/16/head
Logan Williams 2022-02-28 12:54:58 +01:00
rodzic c6b159905b
commit aa4b175dea
2 zmienionych plików z 10 dodań i 11 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)