beetbox / beets

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

discogs: Unhandled exception (HTTP 502: The Discogs API is undergoing maintenance. We'll be back in a moment) #3239

Closed GuilhermeHideki closed 5 years ago

GuilhermeHideki commented 5 years ago

Problem

I had an unhandled exception (temporary error, I guess) with the discogs plugin . I import --quiet .'d the folder and went away for some hours, so I can't reproduce this error now.

The stacktrace:

  File "/beets/beetsplug/discogs.py", line 257, in get_master_year
    year = result.fetch('year')
  File "/usr/lib/python3.7/site-packages/discogs_client/models.py", line 245, in fetch
    self.refresh()
  File "/usr/lib/python3.7/site-packages/discogs_client/models.py", line 211, in refresh
    data = self.client._get(self.data['resource_url'])
  File "/usr/lib/python3.7/site-packages/discogs_client/client.py", line 123, in _get
    return self._request('GET', url)
  File "/usr/lib/python3.7/site-packages/discogs_client/client.py", line 120, in _request
    raise HTTPError(body['message'], status_code)
discogs_client.exceptions.HTTPError: 502: The Discogs API is undergoing maintenance. We'll be back in a moment.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets', 'console_scripts', 'beet')()
  File "/beets/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/beets/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/beets/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/beets/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/beets/beets/importer.py", line 329, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/beets/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/beets/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/beets/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/beets/beets/importer.py", line 1351, in lookup_candidates
    task.lookup_candidates()
  File "/beets/beets/importer.py", line 641, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/beets/beets/autotag/match.py", line 460, in tag_album
    va_likely):
  File "/beets/beets/plugins.py", line 571, in decorated
    for v in generator(*args, **kwargs):
  File "/beets/beets/autotag/hooks.py", line 620, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely):
  File "/beets/beets/plugins.py", line 381, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely):
  File "/beets/beetsplug/discogs.py", line 176, in candidates
    return self.get_albums(query)
  File "/beets/beetsplug/discogs.py", line 245, in get_albums
    return [album for album in map(self.get_album_info, releases[:5])
  File "/beets/beetsplug/discogs.py", line 245, in <listcomp>
    return [album for album in map(self.get_album_info, releases[:5])
  File "/beets/beetsplug/discogs.py", line 335, in get_album_info
    original_year = self.get_master_year(master_id) if master_id else year
  File "/beets/beetsplug/discogs.py", line 262, in get_master_year
    self._log.debug(u'API Error: {0} (query: {1})', e, result._uri)
AttributeError: 'Master' object has no attribute '_uri'

Setup

I don't think the config is relevant on this case, but the import/discogs parts are:

import:                        
    copy: no                   
    move: no                   
    write: no                  
    delete: no                 
    resume: ask                
    incremental: no            
    quiet_fallback: skip       
    none_rec_action: ask       
    timid: no 
    autotag: yes               
    quiet: no                  
    singletons: no             
    default_action: apply
discogs:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    user_token: REDACTED
sampsyo commented 5 years ago

Thanks! Looks like that, in the two places where we currently use result._uri in the error logging call, we need to either remove that lookup or find the new name for that field we want.