mopidy-youtube: Key Error: "u'items'"
Hi, I recently tried to find a youtube video from Mopidy with this plugin, and it seems to crash the whole search feature from Mopidy with a "Key Error: “u’items’” exception. The plugin has been working fine before on my Mopidy setup, and I haven’t changed anything so far, so it’s probably a Youtube side issue?
Just in case I updated pafy and the mopidy-youtube but the issue is still present.
Here is the Traceback.
"Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py", line 133, in _handle_single_request
result = self._unwrap_result(result)
File "/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py", line 222, in _unwrap_result
result = result.get()
File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
compat.reraise(*self._data['exc_info'])
File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
exec('raise tp, value, tb')
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
return callee(*message['args'], **message['kwargs'])
File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 347, in search
result = future.get()
File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
compat.reraise(*self._data['exc_info'])
File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
exec('raise tp, value, tb')
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
return callee(*message['args'], **message['kwargs'])
File "/usr/local/lib/python2.7/dist-packages/mopidy_youtube/backend.py", line 192, in search
tracks=search_youtube(search_query)
File "/usr/local/lib/python2.7/dist-packages/mopidy_youtube/backend.py", line 102, in search_youtube
playlist = [item['id']['videoId'] for item in data['items']]
KeyError: u'items'
"
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19
It looks like the issue stems from an API key issue. There’s no ‘items’ in the data dictionary because the API call itself is returning an error, stating that the key in use is disabled or has never been used.
{u'error': {u'code': 403, u'message': u'Access Not Configured. YouTube Data API has not been used in project 119103001349 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=119103001349 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.', u'errors': [{u'domain': u'usageLimits', u'message': u'Access Not Configured. YouTube Data API has not been used in project 119103001349 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=119103001349 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.', u'reason': u'accessNotConfigured', u'extendedHelp': u'https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=119103001349'}]}}
I worked around this on my machine by registering an API with google and just changing the key (line 23) in mopidy_youtube/backend.py . Not sure that’s a good long-term solution, though.
@custozza I was thinking about the same. If there will be API key in config, it could work just fine. I will try it later today and if it will work on my mopidy I can make merge request.
@ajoshpratt thx for the reply. I’ll try it as soon as I find time. Maybe it would be good to add the API key as config parameter in the ext.conf?