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

Import plugin chromaprint fails everytime with "TypeError: data must be bytes, buffer, or memoryview" #1958

Closed
Bercio opened this issue Apr 26, 2016 · 8 comments
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."

Comments

@Bercio
Copy link

Bercio commented Apr 26, 2016

Problem

beet import fails on some albums (even ones it imported previously without problems), raising a Type Error:

Traceback (most recent call last):
  File "/usr/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.8', 'console_scripts', 'beet')()
  File "/usr/share/beets/beets/ui/__init__.py", line 964, in main
    _raw_main(args)
  File "/usr/share/beets/beets/ui/__init__.py", line 954, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/share/beets/beets/ui/commands.py", line 883, in import_func
    import_files(lib, paths, query)
  File "/usr/share/beets/beets/ui/commands.py", line 855, in import_files
    session.run()
  File "/usr/share/beets/beets/importer.py", line 297, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/share/beets/beets/util/pipeline.py", line 299, in run
    out = self.coro.send(msg)
  File "/usr/share/beets/beets/util/pipeline.py", line 181, in coro
    func(*(args + (task,)))
  File "/usr/share/beets/beets/importer.py", line 1097, in lookup_candidates
    plugins.send('import_task_start', session=session, task=task)
  File "/usr/share/beets/beets/plugins.py", line 403, in send
    handler(**args)
  File "/usr/share/beets/beetsplug/chroma.py", line 196, in fingerprint_task
    acoustid_match(item.path)
  File "/usr/share/beets/beetsplug/chroma.py", line 54, in acoustid_match
    duration, fp = acoustid.fingerprint_file(util.syspath(path))
  File "/usr/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview

Here's a link to the music files that trigger the bug (if relevant):
https://www.dropbox.com/sh/1bawst1nb27u0a6/AAAF7Ggt_7Ljkt57PJh4ofRma?dl=0 (still uploading at the time of writing)

Setup

  • OS: Ubuntu 16.04
  • Python version: 2.7.11+
  • beets version: 1.3.8
  • Turning off plugins made problem go away (yes/no): yes

My configuration (output of beet config) is:

lyrics:
    google_API_key: AIzaSyB8yiWYKHk10wfZ8x_lF8rHHI30WJutS4s
    auto: yes
    fallback:
    google_engine_ID: 009217259823014548361:lndtuqkycfu
rewrite:
    artist Fabrizio .{0,4}Andr.[^\s]?: "Fabrizio De Andr\xE9"
library: /data/Data/musiclibrary.blb
replace:
    '[\\/]': _
    ^\.(?!\.\.): _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    \s+$: ''
    \s: _
    \.\.\.: "\u2026"
original_date: yes
replaygain:
    albumgain: yes
    backend: gstreamer
    targetlevel: 89
    auto: yes
    overwrite: no

plugins: lyrics fetchart embedart replaygain scrub lastgenre mbsync inline rewrite smartplaylist mbcollection convert info chroma fromfilename duplicates

musicbrainz:
    user: bercio
    pass: lorenzo95
per_disc_numbering: yes

paths:
    default: $creator/$album%aunique{}/$disc_and_track-${title}
    singleton: $creator/Singles/$title
    comp: Compilations/$album%aunique{}/$disc_and_track-$title
    albumtype:soundtrack: '%if{$creator,$creator,Soundtracks}/$album/$disc_and_track-$title'
item_fields:
    disc_and_track: u'%02i.%02i' % (disc, track) if disctotal > 1 else u'%02i' % (track)
    creator: u'%s' % (albumartist) if composer == '' or composer == 'Unknown' or composer == albumartist or genre != 'classical' else u'%s/%s' % (composer, albumartist)
log: /var/log/beets.log
smartplaylist:
    playlist_dir: ~/.config/mpd/playlists
    relative_to: /data/Music
    playlists: [{query: '', name: all.m3u}, {query: 'language:ita', name: musica.m3u}]
    auto: yes
ignore: .* *~ *.txt
lastgenre:
    canonical: ''
    count: 1
    source: album
    force: yes
    min_weight: 10
    auto: yes
    whitelist: yes
    separator: ', '
    fallback:

match:
    strong_rec_thresh: 0.11
    medium_rec_thresh: 0.6
directory: /data/Music
acoustid:
    apikey: XLwkkco7
scrub:
    auto: yes
mbcollection:
    auto: no
duplicates:
    album: no
    full: no
    format: ''
    keys: [mb_trackid, mb_albumid]
    move: no
    tag: no
    path: no
    copy: no
    count: no
    checksum:
    delete: no
pathfields: {}
album_fields: {}
embedart:
    auto: yes
    maxwidth: 0
fetchart:
    cautious: no
    maxwidth: 0
    auto: yes
    remote_priority: no
    google_search: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
convert:
    never_convert_lossy_files: no
    format: mp3
    dest:
    auto: no
    threads: 4
    max_bitrate: 500

    paths: {}
    pretend: no
    quiet: no
    formats:
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        aac:
            command: ffmpeg -i $source -y -vn -acodec libfaac -aq 100 $dest
            extension: m4a
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 2 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    embed: yes
@sampsyo
Copy link
Member

sampsyo commented Apr 26, 2016

It looks like you're using beets 1.3.8, which is quite old. Could you please try the latest version?

@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label Apr 26, 2016
@Bercio
Copy link
Author

Bercio commented Apr 26, 2016

beet 1.3.17 produces the same error.

@sampsyo
Copy link
Member

sampsyo commented May 1, 2016

OK, thanks for checking!

It looks like this is the same as #1829, which was resolved by also upgrading to a more recent audioread release. Any chance you could give that a try? If that fixes it, the solution may be to get the more recent release into the Debian repositories.

@Bercio
Copy link
Author

Bercio commented May 3, 2016

Yes, that does seem to fix it, thank you for the responsive care.

@Bercio Bercio closed this as completed May 3, 2016
@sampsyo
Copy link
Member

sampsyo commented May 3, 2016

Great! We'll keep this in mind for others with the same problem.

@interfect
Copy link

I'm having the same problem and the linked solution didn't help. I have Beets 1.3.19, audioread-2.1.4, and pyacoustid-1.1.2, all from pip, on Ubuntu 16.04.

My config looks like:

directory: ~/Music/beets/library
library: ~/Music/beets/musiclibrary.blb

import:
  move: yes

plugins:
    ftintitle chroma

ftintitle:
    drop: yes

My error looks like this:

Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.19', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 967, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 944, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 320, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1257, in lookup_candidates
    plugins.send('import_task_start', session=session, task=task)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 457, in send
    result = handler(**arguments)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 143, in fingerprint_task
    return fingerprint_task(self._log, task, session)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 212, in fingerprint_task
    acoustid_match(log, item.path)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 65, in acoustid_match
    duration, fp = acoustid.fingerprint_file(util.syspath(path))
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview

I'm trying to import MP3 files.

@interfect
Copy link

It looks liken the underlying problem is that chromaprint.py has bytearray when it wants to have a bytes. Since one is just a mutable version of the other, I hacked my chromaprint.py to do the conversion, but I suspect that that's inefficient because now it runs but runs really slow.

@interfect
Copy link

I've put in a PR to pyacoustid that should work around the problem, but really it's probably beets's fault for feeding pyacoustid types that it is documented not to take.

@ghost ghost mentioned this issue Oct 16, 2016
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

3 participants