Add minutes as a unit also
This commit is contained in:
1 parent
c0f52ae12e
commit
b50477e536
1 file changed
+4
-2
@@ -317,7 +317,7 @@ def download_media_metadata(media_id):
|
|||||||
metadata = media.index_metadata()
|
metadata = media.index_metadata()
|
||||||
except YouTubeError as e:
|
except YouTubeError as e:
|
||||||
e_str = str(e)
|
e_str = str(e)
|
||||||
if ': Premieres in' in e_str:
|
if ': Premieres in ' in e_str:
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
published_datetime = None
|
published_datetime = None
|
||||||
|
|
||||||
@@ -325,7 +325,9 @@ def download_media_metadata(media_id):
|
|||||||
unit = lambda p: str(p)[-1].lower()
|
unit = lambda p: str(p)[-1].lower()
|
||||||
number = lambda p: int(str(p)[-2], base=10)
|
number = lambda p: int(str(p)[-2], base=10)
|
||||||
try:
|
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))
|
published_datetime = now + timedelta(hours=number(parts))
|
||||||
elif 'days' == unit(parts):
|
elif 'days' == unit(parts):
|
||||||
published_datetime = now + timedelta(days=number(parts))
|
published_datetime = now + timedelta(days=number(parts))
|
||||||
|
|||||||
Reference in new issue
Block a user