Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thumbnail plugin: "AttributeError: 'bytes' object has no attribute 'encode'" when importing an album #2466

Closed
Armael opened this issue Mar 3, 2017 · 8 comments
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."

Comments

@Armael
Copy link

Armael commented Mar 3, 2017

Problem

For most of the albums I tried lastly, when running beet import /my/album, the thumbnails plugin crashes with the following error:

Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.4', '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 325, 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 358, in run
    self.coro.send(msg)
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 171, in coro
    task = func(*(args + (task,)))
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 1422, in manipulate_files
    session=session,
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 692, in manipulate_files
    plugins.send('import_task_files', session=session, task=self)
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 452, in send
    result = handler(**arguments)
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/beetsplug/fetchart.py", line 814, in assign_art
    self._set_art(task.album, candidate, not self.src_removed)
  File "/usr/lib/python3.6/site-packages/beetsplug/fetchart.py", line 799, in _set_art
    album.set_art(candidate.path, delete)
  File "/usr/lib/python3.6/site-packages/beets/library.py", line 1133, in set_art
    plugins.send('art_set', album=self)
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 452, in send
    result = handler(**arguments)
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/beetsplug/thumbnails.py", line 132, in process_album
    wrote &= self.make_cover_thumbnail(album, 256, LARGE_DIR)
  File "/usr/lib/python3.6/site-packages/beetsplug/thumbnails.py", line 144, in make_cover_thumbnail
    target = os.path.join(target_dir, self.thumbnail_file_name(album.path))
  File "/usr/lib/python3.6/site-packages/beetsplug/thumbnails.py", line 166, in thumbnail_file_name
    hash = md5(uri.encode('utf-8')).hexdigest()
AttributeError: 'bytes' object has no attribute 'encode'

Setup

  • OS: Archlinux
  • Python version: 3.6.0
  • beets version: 1.4.4 (pulled from git today)
  • Turning off plugins made problem go away: yes

My configuration (output of beet config) is:

importfeeds:
    dir: !!binary |
        L3Bvb2wvbXVzaXF1ZQ==
    relative_to:
    formats: m3u
    m3u_name: imported.m3u
    absolute_path: no
directory: /pool/musique
library: /pool/musiclibrary.blb

plugins: fromfilename embedart fetchart lastgenre thumbnails importfeeds
embedart:
    ifempty: yes
    maxwidth: 0
    auto: yes
    compare_threshold: 0
    remove_art_file: no
fetchart:
    enforce_ratio: 5%
    auto: yes
    minwidth: 0
    maxwidth: 0
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    store_source: no
lastgenre:
    count: 5
    force: no
    whitelist: yes
    min_weight: 10
    fallback:
    canonical: no
    source: album
    auto: yes
    separator: ', '
    prefer_specific: no

import:
    incremental: yes
    log: /pool/beets_import.log
thumbnails:
    auto: yes
    force: no
    dolphin: no
@sampsyo
Copy link
Member

sampsyo commented Mar 3, 2017

Hi! Any chance you can get a verbose log leading up to this? There should be a line like this:

using (something) to compute URIs

which should help narrow down where the problem is coming from.

@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label Mar 3, 2017
@Armael
Copy link
Author

Armael commented Mar 3, 2017

Looking at the verbose log, it looks like the corresponding line is thumbnails: using GIO to compute URIs. Should I paste the entire verbose log?

@sampsyo sampsyo closed this as completed in d356356 Mar 3, 2017
@sampsyo
Copy link
Member

sampsyo commented Mar 3, 2017

No, that will do; thanks! I just pushed a possible fix—could you give the new commit a try and see if that solves the problem?

sampsyo added a commit that referenced this issue Mar 3, 2017
@Armael
Copy link
Author

Armael commented Mar 3, 2017

It seems to have fixed the crash, thanks!
I noticed however than the beet import now ends by printing configuration error: importfeeds.dir: must be a filename, not bytes. Is that normal?

@sampsyo
Copy link
Member

sampsyo commented Mar 3, 2017

Great!

That sounds like a separate issue, related to this part of your config:

importfeeds:
    dir: !!binary |
        L3Bvb2wvbXVzaXF1ZQ==

Any particular reason why you have a chunk of binary data in that config option?

@Armael
Copy link
Author

Armael commented Mar 3, 2017

Mmh, this only seems to appear in the output of beet config.

My ~/.config/beets/config.yaml is as follows:

directory: /pool/musique
library: /pool/musiclibrary.blb

plugins: fromfilename embedart fetchart lastgenre thumbnails importfeeds

embedart:
    ifempty: yes

fetchart:
    enforce_ratio: 5%

lastgenre:
    count: 5
    force: no

import:
    incremental: yes
    log: /pool/beets_import.log

importfeeds:
    formats: m3u

@sampsyo
Copy link
Member

sampsyo commented Mar 3, 2017

Very strange. That definitely looks wrong… I think I might see the problem, but would you mind opening another bug to track this?

@Armael
Copy link
Author

Armael commented Mar 3, 2017

Sure, see #2467

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."
Projects
None yet
Development

No branches or pull requests

2 participants