beetbox / beets

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

discogs: sequence item 0: expected str instance, bytes found #2387

Closed bb010g closed 5 years ago

bb010g commented 7 years ago

Problem

On Python 3, an import with discogs enabled fails.

Running this command in verbose (-vv) mode:

nixovo% beet -vv import opus

Led to this problem:

user configuration: /home/bb010g/.config/beets/config.yaml
data directory: /home/bb010g/.config/beets
plugin paths:
Sending event: pluginload
lyrics: Disabling google source: no API key configured.
library database: /home/bb010g/MusicLibrary.blb
library directory: /home/bb010g/Music
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
chroma: chroma: fingerprinted b'/data/arch/bb010g/Downloads/Cave Story/opus/XX - [Every track].opus'
chroma: no match found
Looking up: /data/arch/bb010g/Downloads/Cave Story/opus
Tagging Pixel - Cave Story
No album ID found.
Search terms: Pixel - Cave Story
Album might be VA: False
Sending event: albuminfo_received
Candidate: 開発室Pixel - Cave Story
Success. Distance: 0.32
Sending event: albuminfo_received
Candidate: 開発室Pixel - Cave Story
Success. Distance: 0.11
Sending event: albuminfo_received
Candidate: SUEMITSU & THE NODAME ORCHESTRA - Orchestra de Nodame Story
Success. Distance: 0.68
Sending event: albuminfo_received
Candidate: Various Artists - The Casablanca Records Story
Success. Distance: 0.76
Sending event: albuminfo_received
Candidate: The Idle Race - Back to the Story
Success. Distance: 0.65
chroma: acoustid album candidates: 0
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.3', 'console_scripts', 'beet')()
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1209, in main
    _raw_main(args)
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1196, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.6/site-packages/beets/ui/commands.py", line 930, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.6/site-packages/beets/ui/commands.py", line 907, in import_files
    session.run()
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 319, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3.6/site-packages/six.py", line 686, in reraise
    raise value
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 1261, in lookup_candidates
    task.lookup_candidates()
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 589, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/lib/python3.6/site-packages/beets/autotag/match.py", line 457, in tag_album
    va_likely):
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 496, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/lib/python3.6/site-packages/beets/autotag/hooks.py", line 596, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely):
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 355, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely):
  File "/usr/lib/python3.6/site-packages/beetsplug/discogs.py", line 143, in candidates
    return self.get_albums(query)
  File "/usr/lib/python3.6/site-packages/beetsplug/discogs.py", line 203, in get_albums
    type='release').page(1)
  File "/usr/lib/python3.6/site-packages/discogs_client/client.py", line 144, in search
    fields['q'] = ' '.join(query)
TypeError: sequence item 0: expected str instance, bytes found

Setup

My configuration (output of beet config) is:

directory: ~/Music
library: ~/MusicLibrary.blb

plugins: inline convert web chroma acousticbrainz discogs bpm fetchart lyrics mbsync replaygain scrub the ftintitle badfiles random types info missing

import:
    copy: yes

keyfinder:
    bin: keyfinder-cli

replaygain:
    backend: bs1770gain

types:
    rating: int
sampsyo commented 7 years ago

Hi! Thanks for reporting. Can you check which version of discogs-client you have installed?

For example, I seem to have 2.2.1 installed under both Python 2 and 3 on my system:

$ pip freeze | grep discogs-client
discogs-client==2.2.1
$ pip3 freeze | grep discogs-client
discogs-client==2.2.1

And I can't seem to reproduce the problem in a straightforward way on either Python version.

I also note that we have a workaround in there, referring to #1051 and indirectly to https://github.com/discogs/discogs_client/issues/40, that is probably no longer necessary. This latest version of the library appears able to handle Unicode query inputs (in fact, it prefers them).

inglor commented 7 years ago

On the GitHub repository of discogs_client there's no tag for 2.2.1 version. Python pip though have a 2.2.1 version there. Is there another place? I've just made an issue to tag their release there 75

sampsyo commented 7 years ago

Good point; as far as I can tell, it's only on PyPI.

MadeOfMagicAndWires commented 7 years ago

I'm also running Arch Linux, and am having the same problem, so I can probably help with the info part. If OP installed everything through the official repo and AUR, they'd have the same setup.

$ pacman -Qs discogs
   local/python-discogs-client 2.2.0-2
   local/python2-discogs-client 2.2.0-2

I'll try to see if I can get a package for 2.2.1 and report my findings

MadeOfMagicAndWires commented 7 years ago

switching to 2.2.1 fixes the issue for me. I'll leave my temporary PKGBUILD here and notify the maintainer.

sampsyo commented 7 years ago

Good to know; thank you! And double thanks for notifying the package maintainer.

Meanwhile, I'll update our minimum version in setup.py to 2.2.1 from 2.1.0.

arcresu commented 5 years ago

I think this can be closed now since it looks like Arch has the necessary versions:

sampsyo commented 5 years ago

Excellent news. Thanks for following up.

tim-tx commented 3 years ago

I have been getting this error lately.

Setup

discogs_client version: 2.3.12

Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.5.0', 'console_scripts', 'beet')())
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1278, in main
    _raw_main(args)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1265, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 960, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 930, in import_files
    session.run()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 341, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3.9/site-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1365, in lookup_candidates
    task.lookup_candidates()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 653, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/lib/python3.9/site-packages/beets/autotag/match.py", line 463, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 582, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/lib/python3.9/site-packages/beets/autotag/hooks.py", line 631, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely,
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 391, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely,
  File "/usr/lib/python3.9/site-packages/beetsplug/discogs.py", line 190, in candidates
    return self.get_albums(query)
  File "/usr/lib/python3.9/site-packages/beetsplug/discogs.py", line 252, in get_albums
    releases = self.discogs_client.search(query,
  File "/usr/lib/python3.9/site-packages/discogs_client/client.py", line 134, in search
    fields['q'] = ' '.join(query)
TypeError: sequence item 0: expected str instance, bytes found
sampsyo commented 3 years ago

Hi! Just checking: is this still occurring on the latest source version?

tim-tx commented 3 years ago

Looks like it is not. Thanks

shengdichen commented 3 years ago

I have been getting this error lately.

Setup

* OS: Arch Linux

* Python version: 3.9.5

* beets version: 1.4.9.r1031.cbc045f1c

* Turning off plugins made problem go away (yes/no): yes: discogs

discogs_client version: 2.3.12

Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.5.0', 'console_scripts', 'beet')())
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1278, in main
    _raw_main(args)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1265, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 960, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 930, in import_files
    session.run()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 341, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3.9/site-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1365, in lookup_candidates
    task.lookup_candidates()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 653, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/lib/python3.9/site-packages/beets/autotag/match.py", line 463, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 582, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/lib/python3.9/site-packages/beets/autotag/hooks.py", line 631, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely,
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 391, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely,
  File "/usr/lib/python3.9/site-packages/beetsplug/discogs.py", line 190, in candidates
    return self.get_albums(query)
  File "/usr/lib/python3.9/site-packages/beetsplug/discogs.py", line 252, in get_albums
    releases = self.discogs_client.search(query,
  File "/usr/lib/python3.9/site-packages/discogs_client/client.py", line 134, in search
    fields['q'] = ' '.join(query)
TypeError: sequence item 0: expected str instance, bytes found

Need to report that the same error persists on the following more recent setup:

Would the dev reopen the issue and investigate? Many thanks.

sampsyo commented 3 years ago

Can you please try on the latest source version?

shengdichen commented 3 years ago

Can you please try on the latest source version?

Thanks the speedy response, can confirm that the source-installation works with both 2.3.12-1 (from Arch Linux's repository) and 2.3.12 (from pip) of the discog-client.

For future reference and the baffled newcomers: the official how-to documenting various methods for installing from source.