utils: fix iso8601 parsing

youtube: change datetime format in output
This commit is contained in:
jkhsjdhjs 2020-05-18 20:48:20 +00:00
parent 98646f3226
commit 92d98a1e6c
2 changed files with 5 additions and 2 deletions

View File

@ -9,7 +9,10 @@ def re_generator(low: int = 5, high: int = 20) -> str:
def date_from_iso(date: str) -> datetime:
return datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ')
try:
return datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f%z')
except ValueError:
return datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z')
def is_int(val: str) -> bool:

View File

@ -48,7 +48,7 @@ class YouTube(Plugin):
dislikes=dislikes,
score=score,
views=views,
date=date.strftime('%Y.%m.%d'))
date=date.strftime('%d.%m.%Y %H:%M:%S UTC'))
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(?:youtube.*?(?:v=|/v/)'
r'|youtu\.be/)(?P<video_id>[-_a-zA-Z0-9]+).*')