molly / GorillaBot

IRC bot framework written in Python.
Other
31 stars 15 forks source link

ValueError: time data '2018-05-04T17:42:11Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' #62

Open pep7 opened 3 years ago

pep7 commented 3 years ago

04:02:37 AM - Executor - INFO: Retrieving information from the YouTube API for https://www.youtube.com/watch?v=1jDBhdMMhWM. Exception in thread Executor: Traceback (most recent call last): File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/local/lib/python3.8/threading.py", line 870, in run self._target(*self._args, *self._kwargs) File "/home/gnunix/gorillabot/executor.py", line 65, in loop msg.trigger(msg.args) File "/home/gnunix/gorillabot/plugins/link.py", line 63, in link message = youtube(m, url) File "/home/gnunix/gorillabot/plugins/link.py", line 143, in youtube raw_time = datetime.strptime(blob["snippet"]["publishedAt"], File "/usr/local/lib/python3.8/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/usr/local/lib/python3.8/_strptime.py", line 349, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '2018-05-04T17:42:11Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

!link youtube command fails even with proper API key

Lvl4Sword commented 3 years ago

Your string is missing the microseconds at the end. %f is 000000 - 999999 according to https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes