mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
allow duration_sec extraction to fail cleanly for add to queue
This commit is contained in:
parent
559a4c9a58
commit
63be6afcfe
@ -129,6 +129,8 @@ class PendingList:
|
|||||||
# parse response
|
# parse response
|
||||||
seconds = vid["duration"]
|
seconds = vid["duration"]
|
||||||
duration_str = DurationConverter.get_str(seconds)
|
duration_str = DurationConverter.get_str(seconds)
|
||||||
|
if duration_str == "NA":
|
||||||
|
print(f"skip extracting duration for: {youtube_id}")
|
||||||
upload_date = vid["upload_date"]
|
upload_date = vid["upload_date"]
|
||||||
upload_dt = datetime.strptime(upload_date, "%Y%m%d")
|
upload_dt = datetime.strptime(upload_date, "%Y%m%d")
|
||||||
published = upload_dt.strftime("%Y-%m-%d")
|
published = upload_dt.strftime("%Y-%m-%d")
|
||||||
|
@ -237,6 +237,10 @@ class DurationConverter:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_str(duration_sec):
|
def get_str(duration_sec):
|
||||||
"""takes duration in sec and returns clean string"""
|
"""takes duration in sec and returns clean string"""
|
||||||
|
if not duration_sec:
|
||||||
|
# failed to extract
|
||||||
|
return "NA"
|
||||||
|
|
||||||
hours = duration_sec // 3600
|
hours = duration_sec // 3600
|
||||||
minutes = (duration_sec - (hours * 3600)) // 60
|
minutes = (duration_sec - (hours * 3600)) // 60
|
||||||
secs = duration_sec - (hours * 3600) - (minutes * 60)
|
secs = duration_sec - (hours * 3600) - (minutes * 60)
|
||||||
|
Loading…
Reference in New Issue
Block a user