Add minutes as a unit also

This commit is contained in:
tcely authored and GitHub committed 2025-02-03 10:22:38 -05:00
1 parent c0f52ae12e
commit b50477e536
1 file changed
+4 -2
+4 -2
View File
@@ -317,7 +317,7 @@ def download_media_metadata(media_id):
metadata = media.index_metadata()
except YouTubeError as e:
e_str = str(e)
if ': Premieres in' in e_str:
if ': Premieres in ' in e_str:
now = timezone.now()
published_datetime = None
@@ -325,7 +325,9 @@ def download_media_metadata(media_id):
unit = lambda p: str(p)[-1].lower()
number = lambda p: int(str(p)[-2], base=10)
try:
if 'hours' == unit(parts):
if 'minutes' == unit(parts):
published_datetime = now + timedelta(minutes=number(parts))
elif 'hours' == unit(parts):
published_datetime = now + timedelta(hours=number(parts))
elif 'days' == unit(parts):
published_datetime = now + timedelta(days=number(parts))