rembo10 / headphones

Automatic music downloader for SABnzbd
GNU General Public License v3.0
3.35k stars 603 forks source link

Unable to add new artists - 500 Internal Server Error #3289

Closed skupjoe closed 2 years ago

skupjoe commented 2 years ago

Something happened after the Python3 release. I can search for new artists, but when I click on the artist in the resultset to add it to my database I get an exception.

Reproduce

  1. Search for any new artist. Ie "Summer Walker"
  2. Click on the result. Ie "https://headphones:8181/artistPage?ArtistID=9167f739-da47-4495-9d63-9c13b40114ac
  3. Exception appears in browser:
    
    500 Internal Server Error
    The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last): File "/app/headphones/lib/cherrypy/_cprequest.py", line 638, in respond self._do_respond(path_info) File "/app/headphones/lib/cherrypy/_cprequest.py", line 697, in _do_respond response.body = self.handler() File "/app/headphones/lib/cherrypy/lib/encoding.py", line 223, in call self.body = self.oldhandler(*args, *kwargs) File "/app/headphones/lib/cherrypy/_cpdispatch.py", line 54, in call return self.callable(self.args, **self.kwargs) File "/app/headphones/headphones/webserve.py", line 100, in artistPage artist_extras = list(map(int, artist['Extras'].split(','))) ValueError: invalid literal for int() with base 10: '"1' Powered by CherryPy unknown


An exception also appears in Docker logs:

headphones | 06-Feb-2022 05:11:21 - INFO :: Thread-24 : Checking finished torrents completed headphones | 06-Feb-2022 11:09:27 - INFO :: Thread-15 : Retrieving latest version information from GitHub headphones | 06-Feb-2022 11:09:27 - INFO :: Thread-15 : Headphones is up to date headphones | 06-Feb-2022 12:00:59 - ERROR :: Thread-25 : Uncaught exception: Traceback (most recent call last): headphones | File "/app/headphones/headphones/logger.py", line 215, in new_run headphones | old_run(*args, kwargs) headphones | File "/usr/lib/python3.9/threading.py", line 910, in run headphones | self._target(*self._args, *self._kwargs) headphones | File "/app/headphones/headphones/importer.py", line 162, in addArtisttoDB headphones | artist = mb.getArtist(artistid, extrasonly) headphones | File "/app/headphones/headphones/mb.py", line 313, in getArtist headphones | extras = list(map(int, db_artist['Extras'].split(','))) headphones | ValueError: invalid literal for int() with base 10: '"1' headphones | headphones | Traceback (most recent call last): headphones | File "/app/headphones/headphones/logger.py", line 215, in new_run headphones | old_run(args, kwargs) headphones | File "/usr/lib/python3.9/threading.py", line 910, in run headphones | self._target(*self._args, **self._kwargs) headphones | File "/app/headphones/headphones/importer.py", line 162, in addArtisttoDB headphones | artist = mb.getArtist(artistid, extrasonly) headphones | File "/app/headphones/headphones/mb.py", line 313, in getArtist headphones | extras = list(map(int, db_artist['Extras'].split(','))) headphones | ValueError: invalid literal for int() with base 10: '"1'



### Information
Version: 517d0eb32769db0cd49c745dab23664045d77696
https://github.com/linuxserver/docker-headphones/releases/tag/517d0eb3-ls92
rembo10 commented 2 years ago

Sorry about that, this needs to be fixed, but in the meantime you can edit the config (while headphones is shut down) and remove the quotes from the extras array

skupjoe commented 2 years ago

HI @rembo10 and thanks for the update. I stopped the instance, removed these double quotes from the extras config option, and restarted the container, but I am still getting this error when I click on an artist to add it to my headphones db. Any other ideas?

image

rembo10 commented 2 years ago

Ah ok - I think the double quotes got into the db... I'm just trying to figure out the best way to fix it....

rembo10 commented 2 years ago

I'm still working out the best way to fix this for future users who have the quotes extras in the config, but in the meantime, you can run this script to clean up your database. just run python3 db_fix_extras.py path/to/headphones.db and it'll unquote the extras in the artists table

rembo10 commented 2 years ago

Ok I think I have a fix for this in the develop branch, but unfortunately I think running the script in your case is necessary since you got hit with the bug. So sorry about that EDIT: It's in master

skupjoe commented 2 years ago

Hi again. Thanks- I checked the commits from your merge and they look good and I see the quoting fix. But what I am not sure on is what script should I run to fix my db? I really am missing being able to add new artists, and I am hoping my db can be repaired and stay intact because I've been building on it for 4 or 5 years now! Thanks for the help and the awesome project!

rembo10 commented 2 years ago

You can get it from here: https://gist.github.com/rembo10/0f2d930135be74691d9721701a87b93b

All it does is iterate over the artists table in the database, and strips the quotes from the Extras array

You can download the zip, or just copy and paste it into a file, and run python3 path/to/script.py path/to/headphones.db

skupjoe commented 2 years ago

Thanks- that appears to have fixed it.

Note: I did need to add this to line 14 in order to get past an exception:

    if row[0] is not None:

WLYK if I run into any other issues. Since f41db71 fixes the underlying issue (I'm assuming), I'll go ahead and close this issue for now- thanks again

rembo10 commented 2 years ago

Argg, sorry about that. I updated the script in case anyone else has this issue.... But yeah, f41db71 should prevent the quoted extras strings from getting into the database in the first place.

Thanks for the fix, sorry for all the issues