Key Error: "u'items'"
See original GitHub issueHi, 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'
"
Issue Analytics
- State:
- Created 6 years ago
- Comments:19
Top Results From Across the Web
Python KeyError Exceptions and How to Handle Them
A Python KeyError exception is what is raised when you try to access a key that isn't in a dictionary ( dict )....
Read more >How to Fix KeyError Exceptions in Python - Rollbar
The Python KeyError is an exception that occurs when an attempt is made to access an item in a dictionary that does not...
Read more >I'm getting Key error in python - Stack Overflow
A KeyError generally means the key doesn't exist. So, are you sure the path key exists? From the official python docs: exception KeyError....
Read more >keyerror in Python – How to Fix Dictionary Error
When working with dictionaries in Python, a KeyError gets raised when you try to access an item that doesn't exist in a Python...
Read more >Python KeyError: A Beginner's Guide % - Career Karma
A Python KeyError is raised when you try to access an item in a dictionary that does not exist. You can fix this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.