test: Adds a test to fix #1094 (#1108)

* test: Adds a test to fix #1094

* chore: Formats test file

* fix: Handles floats for published date

* chore: handles another case where published could be a float
This commit is contained in:
Isaac Sanders 2026-01-23 21:14:54 -06:00 committed by GitHub
parent bb1fbd6cf5
commit cc1a2a8a72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View File

@ -406,6 +406,9 @@ class PendingList(PendingIndex):
if timestamp and isinstance(timestamp, int):
return timestamp
if timestamp and isinstance(timestamp, float):
return int(timestamp)
upload_date = video_data.get("upload_date")
if upload_date:
try:

View File

@ -5,6 +5,12 @@ from datetime import datetime, timezone
from download.src.queue import PendingList
def test_returns_scientific_timestamp_if_present():
video_data = {"timestamp": 1.5135732e9}
result = PendingList._extract_published(video_data)
assert result == 1513573200
def test_returns_timestamp_if_present():
video_data = {"timestamp": 1508457600}
result = PendingList._extract_published(video_data)

View File

@ -222,6 +222,9 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
if timestamp and isinstance(timestamp, int):
return timestamp
if timestamp and isinstance(timestamp, float):
return int(timestamp)
upload_date = self.youtube_meta["upload_date"]
if not upload_date:
raise ValueError(