mirror of
https://github.com/instaloader/instaloader.git
synced 2024-11-04 09:22:29 +01:00
Don't rely on fromtimestamp() raising ValueError
Instead of relying on that datetime.fromtimestamp() raises ValueError if the timestamp of a story is in milliseconds rather than seconds, we now compare the timestamp value with a timestamp of the year 2286 to decide whether to divide it by 1000 or not. This is motivated by #30, where an OSError is raised in datetime.fromtimestamp() under Windows.
This commit is contained in:
parent
42864997b3
commit
9eddc03cf1
@ -714,9 +714,9 @@ class Instaloader:
|
||||
shortcode = item["code"] if "code" in item else "no_code"
|
||||
|
||||
date_float = item["device_timestamp"] if "device_timestamp" in item else item["taken_at"]
|
||||
try:
|
||||
if date_float < 10000000000:
|
||||
date = datetime.fromtimestamp(date_float)
|
||||
except ValueError:
|
||||
else:
|
||||
# device_timestamp seems to sometime be in milliseconds
|
||||
date_float /= 1000
|
||||
date = datetime.fromtimestamp(date_float)
|
||||
|
Loading…
Reference in New Issue
Block a user