Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: assume UTC for dates with no timezone (#2158)

Barbarella66666669b9ed45533d8
diff --git a/cyberdrop_dl/utils/dates.py b/cyberdrop_dl/utils/dates.py
index 0623c4044..af07d0e49 100644
--- a/cyberdrop_dl/utils/dates.py
+++ b/cyberdrop_dl/utils/dates.py
@@ -89,7 +89,9 @@ else:
def _normalize(date_time: datetime.datetime) -> datetime.datetime:
- if date_time.tzinfo is not datetime.UTC:
+ if date_time.tzinfo is None:
+ date_time = date_time.replace(tzinfo=datetime.UTC)
+ elif date_time.tzinfo is not datetime.UTC:
date_time = date_time.astimezone(datetime.UTC)
if date_time.microsecond:
return date_time.replace(microsecond=0)
diff --git a/tests/crawlers/test_cases/turbovid.py b/tests/crawlers/test_cases/turbovid.py
index 963c22d6f..a6184ab76 100644
--- a/tests/crawlers/test_cases/turbovid.py
+++ b/tests/crawlers/test_cases/turbovid.py
@@ -8,7 +8,7 @@ TEST_CASES = [
"filename": "E-26dWKftfB.mp4",
"referer": "https://turbo.cr/d/E-26dWKftfB",
"album_id": None,
- "uploaded_at": 1749272400,
+ "uploaded_at": 1749254400,
}
],
},
@@ -20,7 +20,7 @@ TEST_CASES = [
"filename": "E-26dWKftfB.mp4",
"referer": "https://turbo.cr/d/E-26dWKftfB",
"album_id": None,
- "uploaded_at": 1749272400,
+ "uploaded_at": 1749254400,
}
],
},
@@ -32,7 +32,7 @@ TEST_CASES = [
"filename": "E-26dWKftfB.mp4",
"referer": "https://turbo.cr/d/E-26dWKftfB",
"album_id": None,
- "uploaded_at": 1749272400,
+ "uploaded_at": 1749254400,
}
],
},
@@ -45,7 +45,7 @@ TEST_CASES = [
"referer": "https://turbo.cr/d/LM54NzGj8PO",
"download_folder": "re:Qoqsik (TurboVid)",
"album_id": "Bls2Yfbxco0",
- "uploaded_at": 1763269200,
+ "uploaded_at": 1763251200,
}
],
},
@@ -57,7 +57,7 @@ TEST_CASES = [
"filename": "Grumpy Cat.mp4",
"original_filename": "Grumpy Cat.mp4",
"album_id": None,
- "uploaded_at": 1770872400,
+ "uploaded_at": 1770854400,
}
],
},