beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.91k stars 1.82k forks source link

Frequently Crash with "No JSON object could be decoded" #1347

Closed TiBeN closed 9 years ago

TiBeN commented 9 years ago

Hi, I'm renaming my 100go mp3 collection using beets which is great for this purpose. Because i have a lot of not well known vynil EP mp3 rips, i mostly use the discogs plugin. But it crashes very often with this error. I give you two examples bellow.

Context informations: beets version 1.3.10 plugins: discogs

Command line used: beet import -l ~/doc/memos/beet-import-notes ./ Installed and up-to-date at time of writing (discogs plugin included) using pip

/home/tiben/media/aud-vrac/musique/X/X-103 (Aka Jeff Mills)/Thera EP (5 items)
Finding tags for album "X-103 (Aka Jeff Mills) - Thera EP".
Candidates:
1. Jeff Mills - Very EP (60.4%) (tracks, artist, album) (12" Vinyl, 1996, US, Axis)
2. X-103 - Thera EP (42.7%) (tracks, artist) (12" Vinyl, 1992, US, Axis)
3. Jeff Mills - The Other Day EP (35.4%) (tracks, artist, album) (12" Vinyl, 1996, US, Axis)
4. Jeff Mills - Preview (27.0%) (tracks, album, artist) (12" Vinyl, 1999, US, Tomorrow)
5. Thera Roya - Thera Roya (13.1%) (tracks, artist, album) (CD, 2013)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? E
Artist: Jeff Mills
Album: Thera EP
Finding tags for album "X-103 (Aka Jeff Mills) - Thera EP".
Candidates:
1. Jeff Mills - Very EP (60.4%) (tracks, artist, album) (12" Vinyl, 1996, US, Axis)
2. X-103 - Thera EP (42.7%) (tracks, artist) (12" Vinyl, 1992, US, Axis)
3. Jeff Mills - Lifelike EP (38.1%) (tracks, album, artist, ...) (12" Vinyl, 2000, BE, Music Man Records)
4. Jeff Mills - The Other Day EP (35.4%) (tracks, artist, album) (12" Vinyl, 1996, US, Axis)
5. Jeff Mills - Preview (27.0%) (tracks, album, artist) (12" Vinyl, 1999, US, Tomorrow)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? E
Artist: X-103
Album: Thera EP
Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.10', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 945, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 935, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 873, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 845, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 305, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 299, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 181, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1163, in lookup_candidates
    task.lookup_candidates()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 550, in lookup_candidates
    autotag.tag_album(self.items)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/match.py", line 432, in tag_album
    search_album, va_likely)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/hooks.py", line 557, in album_candidates
    out.extend(plugins.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 302, in candidates
    out.extend(plugin.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 118, in candidates
    return self.get_albums(query)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 170, in get_albums
    releases = self.discogs_client.search(query, type='release').page(1)
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/models.py", line 336, in page
    data = self.client._get(self._url_for_page(index))
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/client.py", line 110, in _get
    return self._request('GET', url)
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/client.py", line 102, in _request
    body = json.loads(content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
/home/tiben/media/aud-vrac/musique/VA-minimal_techno 2008-EPs-/Umek_-_Utopia_EP/[RENX056DIGX] Umek - Utopia EP (3 items)
Finding tags for album "Umek - Utopia EP WEB".
Candidates:
1. Umek - Intense Emotion EP (51.7%) (tracks, album) (Digital Media, 2008, DE, Audiomatique Recordings)
2. Umek - Expire EX001 (49.6%) (tracks, album, year) (12" Vinyl, 1997, SI, Expire)
3. Umek - Vice Grip (48.9%) (tracks, album) (Vinyl, 2008, Circle Music)
4. Umek - Pharmacid EP (44.9%) (tracks, album, year) (12" Vinyl, 2003, SI, Consumer Recreation)
5. Umek - The Right Time E.P. (41.0%) (tracks, album, year) (12" Vinyl, 2000, GB, Jericho)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? E
Artist: Umek
Album: Utopia EP
Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.10', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 945, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 935, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 873, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 845, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 305, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 299, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 181, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1163, in lookup_candidates
    task.lookup_candidates()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 550, in lookup_candidates
    autotag.tag_album(self.items)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/match.py", line 432, in tag_album
    search_album, va_likely)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/hooks.py", line 557, in album_candidates
    out.extend(plugins.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 302, in candidates
    out.extend(plugin.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 118, in candidates
    return self.get_albums(query)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 170, in get_albums
    releases = self.discogs_client.search(query, type='release').page(1)
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/models.py", line 336, in page
    data = self.client._get(self._url_for_page(index))
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/client.py", line 110, in _get
    return self._request('GET', url)
  File "/usr/local/lib/python2.7/dist-packages/discogs_client/client.py", line 102, in _request
    body = json.loads(content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
brunal commented 9 years ago

Hi @TiBeN, I just pushed a fix on master. This time it won't crash but discogs won't return you any result.

Could you install the latest git version of beets and try again? To do so, type the following

# pip install git+https://github.com/sampsyo/beets.git@master 

If you then run beets in verbose mode you'll have a message when the discogs API fails, something like discogs: Problem while searching for .... If you want to try again with the --verbose flag and paste here the logs, I'll be able to see what was sent to discogs and therefore determine whether the problem is on our side or on theirs.

TiBeN commented 9 years ago

Hi, Having worked with the discogs API years ago i suspected an unstability related to it. I'll try and give you a feedback as soon as i return at home. Thanks

sampsyo commented 9 years ago

Thanks, @brunal (and @TiBeN). I thought I had found all the places where this exception could come up as of https://github.com/sampsyo/beets/commit/024778544024c52b82cb4ecd09b2cebbb231924c in relation to #1305, but I clearly missed one. The "right" place to fix this eventually is in the discogs library (c.f., https://github.com/discogs/discogs_client/issues/44) so we're stuck working around it for now.

TiBeN commented 9 years ago

Hi @brunal and @sampsyo,

I've tried using master (after uninstalled the previous version using pip uninstall). I think the workaround works as expected as i did not had this error during my tests but I can't confirm because i now have this error everytime i launch the process (ie: my import process locked to this step) :

/home/tiben/media/aud-vrac/musique/Z/Zongamin/ED 007 - Bongo Song (3 items)
Tagging:
    Zongamin - Bongo Song
URL:
    http://musicbrainz.org/release/636c8510-7879-4ead-a69a-77f4cf477c41
(Similarity: 88.0%) (tracks) (12" Vinyl, 2005, FR, Ed Banger Records)
 * Bongo Song (Mr Flash Remix) (#3)     -> Bongo Song (Mr Flash Type C remix) (#2) (index, title)
 * Bongo Song (Jacko Remix) (#2) (5:23) -> Bongo Song (Jackos Bongo Thong (Ripped in 2 Pieces) remix) (#3) (5:47) (title, index, length)
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? A
Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.11', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 953, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 943, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 876, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 853, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 316, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1236, in lookup_candidates
    task.lookup_candidates()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 567, in lookup_candidates
    autotag.tag_album(self.items)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/match.py", line 433, in tag_album
    search_album, va_likely)
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/hooks.py", line 565, in album_candidates
    out.extend(plugins.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 344, in candidates
    out.extend(plugin.candidates(items, artist, album, va_likely))
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 141, in candidates
    self.reset_auth()
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/discogs.py", line 86, in reset_auth
    self.setup()
TypeError: setup() takes exactly 2 arguments (1 given)

To be precise, once i installed the master version, i was able to import somes records (5 or 6), having this error triggered one time or two but not blocking, up to this.

Another point is now each time i launch beet import i'm prompted to go to discogs'url to authorise beets and copy paste code. With previous version i only did it once.

brunal commented 9 years ago

Hi, That crash is caused by a tentative of re-authorization on Discogs. I've fixed it. Could you try it?

Previously if the connection with discogs was lost no re-authorization would happen. Now it re-authorizes, but I have trouble understanding when Discogs ask for it (their implementation of oauth2 loosely follows any standard and does not match their API docs).

brunal commented 9 years ago

That new problem (setup + re-auth) is being discussed in #1345, so let's move further discussion there.

TiBeN commented 9 years ago

OK, I'll report now in the issue #1345. Thanks for your response.