beetbox / beets

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

Beatport Plugin Unhandled Error #3184

Closed mas-4 closed 5 years ago

mas-4 commented 5 years ago

Problem

The beatport plugin kicks back an unhandled error during an import quite frequently. It seems to occur most often during the evening. I am under the impression from the traceback that beatport itself is either throttling me or under unusual high load at the time.

I've been importing a rather massive collection (nearly done, thus far there are 97,908 tracks). I cannot reproduce this error consistently because it seems to occur at the whims of the beatport api. I do not have verbose output and can't provide it because I'm nearly done and just managed to capture the traceback this last time. Also, running consistently in verbose mode makes it difficult to properly interact with the autotagger.

Unfortunately, upon reviewing this traceback, it appears to not be quite as lengthy as I remember. I remember three cascading exceptions, this is merely one of them. If I run into this error again I will try to capture a fuller traceback.

Here is the traceback:

Traceback (most recent call last):
  File "/home/data/music/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/data/music/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/data/music/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
    _raw_main(args)
  File "/home/data/music/venv/src/beets/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/data/music/venv/src/beets/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/home/data/music/venv/src/beets/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/home/data/music/venv/src/beets/beets/importer.py", line 329, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/data/music/venv/src/beets/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/home/data/music/venv/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/data/music/venv/src/beets/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/home/data/music/venv/src/beets/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/home/data/music/venv/src/beets/beets/importer.py", line 1351, in lookup_candidates
    task.lookup_candidates()
  File "/home/data/music/venv/src/beets/beets/importer.py", line 892, in lookup_candidates
    prop = autotag.tag_item(self.item, search_ids=self.search_ids)
  File "/home/data/music/venv/src/beets/beets/autotag/match.py", line 513, in tag_item
    for track_info in hooks.item_candidates(item, search_artist, search_title):
  File "/home/data/music/venv/src/beets/beets/plugins.py", line 571, in decorated
    for v in generator(*args, **kwargs):
  File "/home/data/music/venv/src/beets/beets/autotag/hooks.py", line 640, in item_candidates
    for candidate in plugins.item_candidates(item, artist, title):
  File "/home/data/music/venv/src/beets/beets/plugins.py", line 389, in item_candidates
    for item_candidate in plugin.item_candidates(item, artist, title):
  File "/home/data/music/venv/src/beets/beetsplug/beatport.py", line 361, in item_candidates
    return self._get_tracks(query)
  File "/home/data/music/venv/src/beets/beetsplug/beatport.py", line 460, in _get_tracks
    tracks = [self._get_track_info(x) for x in bp_tracks]
  File "/home/data/music/venv/src/beets/beetsplug/beatport.py", line 460, in <listcomp>
    tracks = [self._get_track_info(x) for x in bp_tracks]
  File "/home/data/music/venv/src/beets/beetsplug/beatport.py", line 134, in search
    facets=['fieldType:{0}'.format(release_type)])
  File "/home/data/music/venv/src/beets/beetsplug/beatport.py", line 194, in _get
    .format(e.message))
AttributeError: 'ConnectionError' object has no attribute 'message'

Setup

My configuration (output of beet config) is:

directory: /home/data/music
library: /home/data/music/musiclibrary.db

import:
    move: yes
    write: yes
    incremental: yes
    detail: yes
    log: /home/data/music/log
    languages: [en]
    autotag: yes
    quiet_fallback: skip
    timid: no
art_filename: albumart
threaded: yes

plugins:
- beatport
- discogs
- chroma
- web
- duplicates
- missing
- lastgenre

ui:
    color: yes

clutter:
- '*.jpg'
- '*.jpeg'
- '*.png'
- '*.gif'
- '*.zip'
- Thumbs.db
- .DS_Store

paths:
    albumtype:soundtrack: Soundtracks/$album/$track $title
beatport:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: beatport_token.json
    source_weight: 0.5
duplicates:
    album: no
    checksum: ''
    copy: ''
    count: no
    delete: no
    format: ''
    full: no
    keys: []
    merge: no
    move: ''
    path: no
    tiebreak: {}
    strict: no
    tag: ''
missing:
    count: no
    total: no
    album: no
chroma:
    auto: yes
lastgenre:
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
discogs:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    user_token: REDACTED
web:
    host: 127.0.0.1
    port: 8337
    cors: ''
    cors_supports_credentials: no
    reverse_proxy: no
    include_paths: no
sampsyo commented 5 years ago

Thanks! I pushed a quick fix. Can you try that out and see if it addresses the problem?

mas-4 commented 5 years ago

I'll pull the changes and update but I can't guarantee I'll hit the issue again anyway. I've been running with the plugin enabled all morning and haven't hit it yet! Thanks for the fix, though. Glad I could help.