joalla / discogs_client

Continuation of the "Official Python Client for the Discogs API"
https://python3-discogs-client.readthedocs.io
Other
309 stars 50 forks source link

TypeError: sequence item 0: expected str instance, bytes found #80

Closed orangepeelbeef closed 2 years ago

orangepeelbeef commented 2 years ago
Traceback (most recent call last):
File "/usr/bin/beet", line 11, in
load_entry_point('beets==1.4.6', 'console_scripts', 'beet')()
File "/usr/share/beets/beets/ui/init.py", line 1256, in main
_raw_main(args)
File "/usr/share/beets/beets/ui/init.py", line 1243, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/share/beets/beets/ui/commands.py", line 937, in import_func
import_files(lib, paths, query)
File "/usr/share/beets/beets/ui/commands.py", line 914, in import_files
session.run()
File "/usr/share/beets/beets/importer.py", line 327, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/share/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/dist-packages/six.py", line 693, in reraise
raise value
File "/usr/share/beets/beets/util/pipeline.py", line 312, in run
out = self.coro.send(msg)
File "/usr/share/beets/beets/util/pipeline.py", line 194, in coro
func(*(args + (task,)))
File "/usr/share/beets/beets/importer.py", line 1346, in lookup_candidates
task.lookup_candidates()
File "/usr/share/beets/beets/importer.py", line 636, in lookup_candidates
autotag.tag_album(self.items, search_ids=self.search_ids)
File "/usr/share/beets/beets/autotag/match.py", line 460, in tag_album
va_likely):
File "/usr/share/beets/beets/plugins.py", line 496, in decorated
for v in generator(*args, **kwargs):
File "/usr/share/beets/beets/autotag/hooks.py", line 601, in album_candidates
for candidate in plugins.candidates(items, artist, album, va_likely):
File "/usr/share/beets/beets/plugins.py", line 355, in candidates
for candidate in plugin.candidates(items, artist, album, va_likely):
File "/usr/share/beets/beetsplug/discogs.py", line 151, in candidates
return self.get_albums(query)
File "/usr/share/beets/beetsplug/discogs.py", line 211, in get_albums
type='release').page(1)
File "/usr/local/lib/python3.6/dist-packages/discogs_client/client.py", line 134, in search
fields['q'] = ' '.join(query)
TypeError: sequence item 0: expected str instance, bytes found

python 3.6.9

79

AnssiAhola commented 2 years ago

Hi @orangepeelbeef !

Thanks for submitting the PR for a fix. Could you tell us the steps to replicate this bug? Or a code snippet where this bug occurs on you app. So we can verify and test it ourselves 🙂

zerinoid commented 2 years ago

I'm having the same error using 'beet import folder'

JOJ0 commented 2 years ago

I'm having the same error using 'beet import folder'

Interesting, I never have problems with beet import and discogs plugin.

Also Python 3.6? Which discogs_client version?

zerinoid commented 2 years ago

python3-discogs-client==2.3.14

python 3.9.7

JOJ0 commented 2 years ago

edited original post for readability.

JOJ0 commented 2 years ago

@zerinoid thanks a lot so far. that helps.

Sorry for bothering again: Can you tell us the exact track it happens with? Is it always at the same one or randomely?

zerinoid commented 2 years ago

It happend with several albuns I tried to add

JOJ0 commented 2 years ago

@zerinoid can you reproduce it? I.e. delete the albums from beets again, use the original untagged mp3s, import again, does it happen again? Sorry I for bothering but we need to find a way to force the error to be able to fix it :-)

zerinoid commented 2 years ago

The albuns are actually not added when this happens

zerinoid commented 2 years ago
❯ beet import Memo\ Boy\ -\ Songs\ \&\ Demos\ 2015-2017
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/usr/share/beets/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/share/beets/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/share/beets/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/usr/share/beets/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/usr/share/beets/beets/importer.py", line 329, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/share/beets/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/local/lib/python3.9/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/share/beets/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/share/beets/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/share/beets/beets/importer.py", line 1351, in lookup_candidates
    task.lookup_candidates()
  File "/usr/share/beets/beets/importer.py", line 641, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/share/beets/beets/autotag/match.py", line 457, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/usr/share/beets/beets/plugins.py", line 574, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/share/beets/beets/autotag/hooks.py", line 620, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely):
  File "/usr/share/beets/beets/plugins.py", line 384, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely):
  File "/usr/share/beets/beetsplug/discogs.py", line 176, in candidates
    return self.get_albums(query)
  File "/usr/share/beets/beetsplug/discogs.py", line 237, in get_albums
    releases = self.discogs_client.search(query,
  File "/home/zerinol/.local/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

no output for:

❯ beet ls Memo

zerinoid commented 2 years ago
❯ beet import BbyMutha\ -\ 2016\ -\ Glow\ Kit\ \(WEB\ FLAC\)
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/usr/share/beets/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/share/beets/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/share/beets/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/usr/share/beets/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/usr/share/beets/beets/importer.py", line 329, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/share/beets/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/local/lib/python3.9/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/share/beets/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/share/beets/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/share/beets/beets/importer.py", line 1351, in lookup_candidates
    task.lookup_candidates()
  File "/usr/share/beets/beets/importer.py", line 641, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/share/beets/beets/autotag/match.py", line 457, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/usr/share/beets/beets/plugins.py", line 574, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/share/beets/beets/autotag/hooks.py", line 620, in album_candidates
    for candidate in plugins.candidates(items, artist, album, va_likely):
  File "/usr/share/beets/beets/plugins.py", line 384, in candidates
    for candidate in plugin.candidates(items, artist, album, va_likely):
  File "/usr/share/beets/beetsplug/discogs.py", line 176, in candidates
    return self.get_albums(query)
  File "/usr/share/beets/beetsplug/discogs.py", line 237, in get_albums
    releases = self.discogs_client.search(query,
  File "/home/zerinol/.local/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

same

zerinoid commented 2 years ago

when a query is found in music brainz, it works fine:

❯ beet import 2013\ -\ Stone\ Island

/home/zerinol/music/redacted/2013 - Stone Island (10 items)
Tagging:
    Dean Blunt - Stone Island
URL:
    https://musicbrainz.org/release/bef1a4fa-2ce9-4265-aa7f-214876f34adf
(Similarity: 100.0%) (Digital Media, 2013)
JOJ0 commented 2 years ago

Great thanks for all the details!


❯ beet import Memo\ Boy\ -\ Songs\ \&\ Demos\ 2015-2017
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>

And when you now try to import that song again, does it happen again? Each time the same error?

If for example you try to import that exact song again, right now! Does the error happen again or does it work then?

Sorry I need to ask that so precisely to find out where and what is causing this....Thanks for you patience and support!

zerinoid commented 2 years ago

yes, it happens again, same error. It is not a song, it's an album folder. The error happens all the time

On Wed, 6 Apr 2022 at 09:58, J0J0 T @.***> wrote:

Great thanks for all the details!

❯ beet import Memo\ Boy\ -\ Songs\ \&\ Demos\ 2015-2017

Traceback (most recent call last):

File "/usr/bin/beet", line 11, in

And when you now try to import that song again, does it happen again? Each time the same error?

If for example you try to import that exact song again, right now! Does the error happen again or does it work sometimes?

Sorry I need to ask that so preciselfy to find out where and what is causing this....Thanks for you patience and support!

— Reply to this email directly, view it on GitHub https://github.com/joalla/discogs_client/issues/80#issuecomment-1090238647, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI44TXCWEGLSVHECZBKDPT3VDWC6TANCNFSM5O5FWY3Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Leonardo Zerino (11)98479.9777

JOJ0 commented 2 years ago

that's actually good news. so it's perfectly reproducable. thanks so much for taking the time to analyze this!

JOJ0 commented 2 years ago

❯ beet import BbyMutha\ -\ 2016\ -\ Glow\ Kit\ \(WEB\ FLAC\)

Sorry for bothering again @zerinoid. What we would need from you would be an exact link to an release on Discogs where that happens. The only way for us to reproduce is to know what releases on Discogs are potentially replied differently by the api. So could you tell us the exact link to the discogs release of this artist: Bbymutha, that is found in above mendioned flac files.

Thanks so much!!!

zerinoid commented 2 years ago

well, as you can see in the output, no release is found as no link is provided.

On Fri, 8 Apr 2022 at 12:58, J0J0 T @.***> wrote:

❯ beet import BbyMutha\ -\ 2016\ -\ Glow\ Kit\ (WEB\ FLAC)

Sorry for bothering again @zerinoid https://github.com/zerinoid. What we would need from you would be an exact link to an release on Discogs where that happens. The only way for us to reproduce is to know what releases on Discogs are potentially replied differently. So could you tell us the exact link to the discogs release of this artist: Bbymutha, that is found in above mendioned flac files.

Thanks so much!!!

— Reply to this email directly, view it on GitHub https://github.com/joalla/discogs_client/issues/80#issuecomment-1093036177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI44TXFA7TBNIQXSUGTSBNLVEBJSDANCNFSM5O5FWY3Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Leonardo Zerino (11)98479.9777

JOJ0 commented 2 years ago

well, as you can see in the output, no release is found as no link is provided.

Well, I had understood that wrong: The problem is in the search, not in the release fetching.

We think we fixed that error, if you feel like it, it would help to test this in real life. The PR is merged, thus code in master: https://github.com/joalla/discogs_client/pull/94

To use discogs_client from git-master directly you'd need to install like this:

$ pip uninstall discogs_client
$ git clone https://github.com/joalla/discogs_client
$ cd discogs_client
$ pip install --editable .

Check if installed correctly (should show the path of your cloned repo):

$ pip list -v | grep discogs
python3-discogs-client 2.3.14    /tmp/discogs_client       /tmp/discogs_client
JOJ0 commented 2 years ago

@orangepeelbeef also for you: If you find the time: It would help if you'd install discogs-client from git directly and use it like that with your beets installation.

We'd like to get some responses before we put this in a release on PyPI.

Thanks in advance!

zerinoid commented 2 years ago

Thank you, sorry for not having time to test it right now :(

On Thu, 19 May 2022 at 10:21, J0J0 T @.***> wrote:

@orangepeelbeef https://github.com/orangepeelbeef also for you: If you find the time: It would help if you'd install discogs-client from git directly and use it like that with your beets installation.

We'd like to get some responses before we put this in a release on PyPI.

Thanks in advance!

— Reply to this email directly, view it on GitHub https://github.com/joalla/discogs_client/issues/80#issuecomment-1131681068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI44TXHL2CCL67RHTZVGCQLVKY54VANCNFSM5O5FWY3Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Leonardo Zerino (11)98479.9777

JOJ0 commented 2 years ago

It's released already. Many thanks anyway :-)