* 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:
parent
bb1fbd6cf5
commit
cc1a2a8a72
|
|
@ -406,6 +406,9 @@ class PendingList(PendingIndex):
|
||||||
if timestamp and isinstance(timestamp, int):
|
if timestamp and isinstance(timestamp, int):
|
||||||
return timestamp
|
return timestamp
|
||||||
|
|
||||||
|
if timestamp and isinstance(timestamp, float):
|
||||||
|
return int(timestamp)
|
||||||
|
|
||||||
upload_date = video_data.get("upload_date")
|
upload_date = video_data.get("upload_date")
|
||||||
if upload_date:
|
if upload_date:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ from datetime import datetime, timezone
|
||||||
from download.src.queue import PendingList
|
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():
|
def test_returns_timestamp_if_present():
|
||||||
video_data = {"timestamp": 1508457600}
|
video_data = {"timestamp": 1508457600}
|
||||||
result = PendingList._extract_published(video_data)
|
result = PendingList._extract_published(video_data)
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,9 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
||||||
if timestamp and isinstance(timestamp, int):
|
if timestamp and isinstance(timestamp, int):
|
||||||
return timestamp
|
return timestamp
|
||||||
|
|
||||||
|
if timestamp and isinstance(timestamp, float):
|
||||||
|
return int(timestamp)
|
||||||
|
|
||||||
upload_date = self.youtube_meta["upload_date"]
|
upload_date = self.youtube_meta["upload_date"]
|
||||||
if not upload_date:
|
if not upload_date:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue