Open JeppeTh opened 10 years ago
Strange error, pretty sure I know what's happening here though.
Will include a fix for this in the next release.
This issue shouldn't exist in the beta release.
It does: "UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position 135: invalid start byte"...
2014-05-14 10:22:22,530 (1a30) : DEBUG (logkit:13) - [spotify.components.connection] send encoded: '{"args":["before the dawn",15,7,0],"name":"sp/search","id":"7"}'
2014-05-14 10:22:22,780 (74c) : DEBUG (logkit:13) - [pyemitter] emit(event: 'message', args: (), kwargs: {'message': '{"id":7,"result":"<?xml version=\'1.0\' encoding=\'utf-8\'?>
Couldn't find what is causing unicode/utf-8 to fail and wasn't able to reproduce the issue on a Windows XP VM (this issue seems to be Windows XP/NT specific).
I've decided to just normalize everything to ASCII instead (removing all the use of unicode/utf-8), could you grab the development version (develop.zip) and let me know if this fixes searching.
Is develop.zip ready for that? SInce when tried I still get UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position 135: invalid start byte
Just noticed there were some places where unicode was still used, try the latest develop version now.
If you still find it breaking, let me know which view it breaks on (search results, artist, album, playlist) and send the full error stack-trace (like what you did with the original issue).
I still get the same issue searching for e.g. "Before the dawn". I can try to collect logs later on...
Heres the log
2014-05-23 13:52:41,546 (1730) : INFO (logkit:16) - Search query: "before the dawn", type: all, count: 7, plain: False
2014-05-23 13:52:41,546 (1730) : DEBUG (logkit:13) - [pyemitter] on(events: ['success'], func: <function on_search at 0x03EF8E70>)
2014-05-23 13:52:41,562 (1730) : DEBUG (logkit:13) - [spotify.components.connection] send encoded: '{"args":["before the dawn",15,7,0],"name":"sp/search","id":"11"}'
2014-05-23 13:52:41,717 (12b0) : DEBUG (logkit:13) - [pyemitter] emit(event: 'message', args: (), kwargs: {'message': '{"id":11,"result":"<?xml version=\'1.0\' encoding=\'utf-8\'?>
It must be this that fails or? xml = etree.fromstring(data['result'].encode('utf-8'))
in Contents\Libraries\Shared\spotify\core\search_response.py
In the latest version I changed a %s to a %r in search.py to get searching to work, Sometimes the number of songs is shown incorrectly - but at least I get a usable result
title = '%s (%r)' % (
cls.get_title(type, True),
locale.format('%d', total, grouping=True)
)
it seems there are some unicode spaces or similar that mess things up '\xa0' - i.e. when hitting more than e.g. 1000 tracks.
This variant also seems to work (if you import re): title = '%s (%s)' % ( cls.get_title(type, True), re.sub("\xa0", "", locale.format('%d', total, grouping=True)) )
locale.format
is used to format numbers to your locale (e.g. 1000
= 1,000
in NZ), looks like the \xa0
(non-breaking space) character is used in some locales as the grouping separator though.
I'll need to look at why "%r" is needed here, but will get this fixed in the main branch later today.
https://forums.plex.tv/index.php/topic/107169-rel-spotify2/page-2#entry636557
Sometimes I instead get "print 'unable to find node for "%s"' % key IOError: [Errno 9] Bad file descriptor"
2014-04-26 21:29:11,890 (5e4) : DEBUG (runtime:717) - Handling request GET /music/spotify/search?query=before%20the%20dawn 2014-04-26 21:29:11,890 (5e4) : DEBUG (runtime:814) - Found route matching /music/spotify/search 2014-04-26 21:29:11,890 (5e4) : INFO (logkit:16) - Search query: "before the dawn", type: all, limit: 7, plain: False 2014-04-26 21:29:11,890 (5e4) : DEBUG (logkit:13) - sent {"args":["before the dawn",15,7,0],"name":"sp/search","id":"21"} 2014-04-26 21:29:12,030 (1560) : DEBUG (logkit:13) - recv {"id":21,"result":"<?xml version='1.0' encoding='utf-8>"} 2014-04-26 21:29:12,108 (5e4) : CRITICAL (core:561) - Exception (most recent call last): File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\runtime.py", line 843, in handle_request result = f(d) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Codeinit.py", line 59, in search return sp_search.run(kwargs) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\code\sandbox.py", line 19, in _apply return apply(f, args, kwargs) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Code\search.py", line 95, in run media_append('Playlists', self.add_playlist, 'playlists') File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Code\search.py", line 70, in media_append items = list(getattr(result, 'get%s' % key)()) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Libraries\Shared\spotify_web\search.py", line 105, in getObjects yield self.parse(obj_type, item) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Libraries\Shared\spotify_web\search.py", line 95, in parse return Playlist.parse(item) File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Libraries\Shared\spotify_web\search.py", line 303, in parse image_uri = cls.get_value(node, 'image') File "C:\Documents and Settings\Owner\Local Settings\Application Data\Plex Media Server\Plug-ins\Spotify2.bundle\Contents\Libraries\Shared\spotify_web\search.py", line 123, in get_value print 'unable to find node for "%s"' % key IOError: [Errno 9] Bad file descriptor