From cc1a2a8a72bde0dfaa3e1ae40e0b92dc56d6a1ea Mon Sep 17 00:00:00 2001 From: Isaac Sanders <651597+isaacsanders@users.noreply.github.com> Date: Fri, 23 Jan 2026 21:14:54 -0600 Subject: [PATCH] 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 --- backend/download/src/queue.py | 3 +++ backend/download/tests/test_src/test_pending_list.py | 6 ++++++ backend/video/src/index.py | 3 +++ 3 files changed, 12 insertions(+) diff --git a/backend/download/src/queue.py b/backend/download/src/queue.py index fa532925..cb259f82 100644 --- a/backend/download/src/queue.py +++ b/backend/download/src/queue.py @@ -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: diff --git a/backend/download/tests/test_src/test_pending_list.py b/backend/download/tests/test_src/test_pending_list.py index f8656c7c..244fa4f4 100644 --- a/backend/download/tests/test_src/test_pending_list.py +++ b/backend/download/tests/test_src/test_pending_list.py @@ -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) diff --git a/backend/video/src/index.py b/backend/video/src/index.py index 69f7ac5c..5226e651 100644 --- a/backend/video/src/index.py +++ b/backend/video/src/index.py @@ -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(