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(