DocMarty84 / koozic

Self-hosted media streaming server
https://koozic.net
Other
90 stars 12 forks source link

Artist Bio Error on DSub and koozic 2.2.0 #31

Closed jprenaudet closed 5 years ago

jprenaudet commented 5 years ago

Hello,

As always, very good work with the V2.2.0 release.

Environment:

Bug: When browsing library in DSub, on artist page, there is an Artist Bio display at top of screen. With the new V2.2.0 (V2.1.0 is OK), nothing is shown and a error popup :

A network error occurred. Please check the server address or try again later.

Server log:

Aug 18 17:57:26 audio odoo-bin[20280]: 2019-08-18 15:57:26,286 20280 ERROR koozicDB werkzeug: Error on request:
Aug 18 17:57:26 audio odoo-bin[20280]: Traceback (most recent call last):
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 205, in run_wsgi
Aug 18 17:57:26 audio odoo-bin[20280]:     execute(self.server.app)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 193, in execute
Aug 18 17:57:26 audio odoo-bin[20280]:     application_iter = app(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/service/server.py", line 409, in app
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.app(e, s)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/service/wsgi_server.py", line 126, in application
Aug 18 17:57:26 audio odoo-bin[20280]:     return werkzeug.contrib.fixers.ProxyFix(application_unproxied)(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/usr/lib/python3/dist-packages/werkzeug/contrib/fixers.py", line 152, in __call__
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.app(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/service/wsgi_server.py", line 117, in application_unproxied
Aug 18 17:57:26 audio odoo-bin[20280]:     result = odoo.http.root(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 1318, in __call__
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.dispatch(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 1291, in __call__
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.app(environ, start_wrapped)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/usr/lib/python3/dist-packages/werkzeug/wsgi.py", line 599, in __call__
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.app(environ, start_response)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 1486, in dispatch
Aug 18 17:57:26 audio odoo-bin[20280]:     result = ir_http._dispatch()
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/addons/web_editor/models/ir_http.py", line 22, in _dispatch
Aug 18 17:57:26 audio odoo-bin[20280]:     return super(IrHttp, cls)._dispatch()
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/addons/base/models/ir_http.py", line 207, in _dispatch
Aug 18 17:57:26 audio odoo-bin[20280]:     return cls._handle_exception(e)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/addons/base/models/ir_http.py", line 177, in _handle_exception
Aug 18 17:57:26 audio odoo-bin[20280]:     return request._handle_exception(exception)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 774, in _handle_exception
Aug 18 17:57:26 audio odoo-bin[20280]:     return super(HttpRequest, self)._handle_exception(exception)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 312, in _handle_exception
Aug 18 17:57:26 audio odoo-bin[20280]:     raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/tools/pycompat.py", line 87, in reraise
Aug 18 17:57:26 audio odoo-bin[20280]:     raise value
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/addons/base/models/ir_http.py", line 203, in _dispatch
Aug 18 17:57:26 audio odoo-bin[20280]:     result = request.dispatch()
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 833, in dispatch
Aug 18 17:57:26 audio odoo-bin[20280]:     r = self._call_function(**self.params)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 344, in _call_function
Aug 18 17:57:26 audio odoo-bin[20280]:     return checked_call(self.db, *args, **kwargs)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/service/model.py", line 97, in wrapper
Aug 18 17:57:26 audio odoo-bin[20280]:     return f(dbname, *args, **kwargs)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 337, in checked_call
Aug 18 17:57:26 audio odoo-bin[20280]:     result = self.endpoint(*a, **kw)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 939, in __call__
Aug 18 17:57:26 audio odoo-bin[20280]:     return self.method(*args, **kw)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/odoo/http.py", line 517, in response_wrap
Aug 18 17:57:26 audio odoo-bin[20280]:     response = f(*args, **kw)
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/addons/oomusic/controllers/subsonic/browsing.py", line 312, in getArtistInfo
Aug 18 17:57:26 audio odoo-bin[20280]:     folder, count=count, includeNotPresent=includeNotPresent
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/addons/oomusic/controllers/subsonic/common.py", line 554, in make_ArtistInfo
Aug 18 17:57:26 audio odoo-bin[20280]:     base_artist_info = self._make_ArtistInfoBase(artist[0])
Aug 18 17:57:26 audio odoo-bin[20280]:   File "/opt/koozic/addons/oomusic/controllers/subsonic/common.py", line 532, in _make_ArtistInfoBase
Aug 18 17:57:26 audio odoo-bin[20280]:     item = req_json["artists"]["items"][0] if req_json["artists"]["items"] else {}
Aug 18 17:57:26 audio odoo-bin[20280]: KeyError: 'artists' 40 0.035 0.954
DocMarty84 commented 5 years ago

Hello,

Does it happen for all artists, or only one in particular? You could try to to go on the artist page, then Action > Update Artist Info.

It seems that the Spotify image was not fetched correctly, so refreshing the info might solve the problem.

DocMarty84 commented 5 years ago

I'll publish a fix soon to avoid crashing but log the error.

jprenaudet commented 5 years ago

Yes it happen on all artists I tried (4/5 different : Daft Punk, Corinne, Brigitte...).

Don't know if it's relevant, but on the website, I don't have artist images display (the bio from lastfm is ok). No error from log when I'm on the website. Can't remember if it was like this with V2.1.0.

I try to update artist info, but nothing change.

I'll publish a fix soon to avoid crashing but log the error.

Ok great, thank you :)

DocMarty84 commented 5 years ago

On the website the error is catched, but not from the Subsonic API. So you don't see any error in the interface, but you should see an error in the log.

What is surprising is that refreshing the info doesn't solve the issue. I'll also have a look to log the request done to Spotify so I can reproduce the problem on my side, not only hide it 😊

DocMarty84 commented 5 years ago

By the way, can you check if there is some error reported in the log when you update the artist info? I realized there are already a couple of things logged in case of error, so it might be helpful.

Thanks

jprenaudet commented 5 years ago

Here as the log when I update artist info:

I also try to wget the spotify uri, here is the log :

xxx@xxx:~$ wget https://api.spotify.com/v1/search?type=artist&limit=1&q=Daft+Punk
[1] 32359
[2] 32360
xxx@xxx:~$ --2019-08-19 11:25:22--  https://api.spotify.com/v1/search?type=artist
Resolving api.spotify.com (api.spotify.com)... 35.186.224.53
Connecting to api.spotify.com (api.spotify.com)|35.186.224.53|:443... connected.
HTTP request sent, awaiting response... 401 Unauthorized

Username/Password Authentication Failed.

[1]-  Exit 6                  wget https://api.spotify.com/v1/search?type=artist
[2]+  Done                    limit=1

Maybe MusicBrainz or discogs could be use to retreive images without the need of authentification.

DocMarty84 commented 5 years ago

Thanks, that was helpful.

This is the faulty part:

Aug 19 11:24:14 audio odoo-bin[31932]:   File "/opt/koozic/addons/oomusic/models/oomusic_spotify.py", line 141, in _get_token
Aug 19 11:24:14 audio odoo-bin[31932]:     content = json.loads(res.content)
Aug 19 11:24:14 audio odoo-bin[31932]:   File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
Aug 19 11:24:14 audio odoo-bin[31932]:     s.__class__.__name__))
Aug 19 11:24:14 audio odoo-bin[31932]: TypeError: the JSON object must be str, not 'bytes'

This is due to a difference between Python 3.5 and 3.6.

In 3.5:

Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.loads('{}')
{}
>>> json.loads(b'{}')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

In 3.6:

Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.loads('{}')
{}
>>> json.loads(b'{}')
{}

For reference: https://github.com/python/cpython/commit/b161562f72a28e83e62ec0a0a5de601e7724629f

I always test in 3.6 (Ubuntu 18.04), but not in 3.5...

The fix is quite easy to apply: https://github.com/DocMarty84/oomusic/pull/7

I'll publish a new version ASAP.

DocMarty84 commented 5 years ago

v2.2.1 released: https://github.com/DocMarty84/koozic/releases/tag/v2.2.1

jprenaudet commented 5 years ago

Great !! That was quick, thank you :smiley:

I'll test it this afternoon.
Thank you again.