beetbox / mediafile

elegant audio file tagging
http://mediafile.readthedocs.io/
MIT License
100 stars 26 forks source link

(Bug) import - mediafile.py issue #56

Closed lbesnard closed 3 years ago

lbesnard commented 3 years ago

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import . 

Led to this problem:

/home/home/src/beets/beets/mediafile.py:21: UserWarning: beets.mediafile is deprecated; use mediafile instead
  warnings.warn("beets.mediafile is deprecated; use mediafile instead")
....
....
....
Success. Distance: 0.49
Requesting MusicBrainz release 1e4666e0-bfd7-4e00-88b6-101d18fe024a
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
primary MB release type: ep
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Nick Curly - Sun City EP (1e4666e0-bfd7-4e00-88b6-101d18fe024a)
Computing track assignment...
...done.
Success. Distance: 0.52
Evaluating 4 candidates.
Traceback (most recent call last):
  File "/home/home/miniconda3/bin/beet", line 11, in <module>
    load_entry_point('beets', 'console_scripts', 'beet')()
  File "/home/home/src/beets/beets/ui/__init__.py", line 1291, in main
    _raw_main(args)
  File "/home/home/src/beets/beets/ui/__init__.py", line 1278, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/home/src/beets/beets/ui/commands.py", line 973, in import_func
    import_files(lib, paths, query)
  File "/home/home/src/beets/beets/ui/commands.py", line 943, in import_files
    session.run()
  File "/home/home/src/beets/beets/importer.py", line 341, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/home/src/beets/beets/util/pipeline.py", line 442, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/home/home/miniconda3/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/home/src/beets/beets/util/pipeline.py", line 259, in run
    msg = next(self.coro)
  File "/home/home/src/beets/beets/importer.py", line 1320, in read_tasks
    for t in task_factory.tasks():
  File "/home/home/src/beets/beets/importer.py", line 1144, in tasks
    tasks = self._create(self.album(paths, dirs))
  File "/home/home/src/beets/beets/importer.py", line 1224, in album
    items = [item for item in items if item]
  File "/home/home/src/beets/beets/importer.py", line 1224, in <listcomp>
    items = [item for item in items if item]
  File "/home/home/src/beets/beets/importer.py", line 1273, in read_item
    return library.Item.from_path(path)
  File "/home/home/src/beets/beets/library.py", line 603, in from_path
    i.read(path)
  File "/home/home/src/beets/beets/library.py", line 710, in read
    value = getattr(mediafile, key)
  File "/home/home/miniconda3/lib/python3.7/site-packages/mediafile.py", line 1276, in __get__
    out = style.get(mediafile.mgfile)
  File "/home/home/miniconda3/lib/python3.7/site-packages/mediafile.py", line 612, in get
    return self.get_list(mutagen_file)[0]
  File "/home/home/miniconda3/lib/python3.7/site-packages/mediafile.py", line 619, in get_list
    return [self.deserialize(item) for item in self.fetch(mutagen_file)]
  File "/home/home/miniconda3/lib/python3.7/site-packages/mediafile.py", line 951, in fetch
    return sum([el.split('/') for el in frame.text], start=[])
TypeError: sum() takes no keyword arguments

This is only happening with some folders, but I can't pin-point to what exactly. I have had a few similar issues since the new release, and wondering if it's not related to the mediafile warning above

Setup

My configuration (output of beet config) is:

acousticbrainz:
    auto: yes

badfiles:
    commands: {}
    #    commands:
    #    ogg: myoggchecker --opt1 --opt2
    #    flac: flac --test --warnings-as-errors --silent

chroma:
    auto: yes

convert:
    auto: no
    never_convert_lossy_files: yes
    quiet: false
    dest: /tmp/convert
    formats:
      alac:
        command: ffmpeg -i $source -y -vn -aq 2 $dest
        extension: flac

directory: /export/music/beet_library/

duplicates:
    album: yes
    path: yes

fetchart:
    auto: yes
    maxwidth: 1000
    cover_names: cover Cover front Front art album portada folder Folder
    google-key:
    sources:
        - filesystem
        - coverart: release
        - itunes
        - covertart: releasegroup
        - amazon
        - albumart
        - google
        - '*'

ftintitle:
    auto: yes

import:
    copy: no
    move: yes
    write: yes
    languages: en
    resume: yes
    autotag: yes

item_fields:
    multidisc: 1 if disctotal > 1 else 0
    genre_fix: genre.title()
    genre_no_space: genre.lower().replace(' ','_')

lastgenre:
    auto: yes
    fallback: 'unknown'
    source: artist
    canonical: ~/.config/beets/genres-tree.yaml
    whitelist: ~/.config/beets/beets_genre
    #prefer_specific: true

wlg:
    auto: no
    force: no
    count: 1
    separator: ', '
    whitelist: ~/.config/beets/beets_genre

library: /export/music/musiclibrary2.blb

replaygain:
    backend: ffmpeg

sort_item: albumartist+ album+ disc+ track+

spotify:
    mode: open
    region_filter: US
    show_failures: on
    tiebreak: popularity
    regex: [
        {
            field: "albumartist", # Field in the item object to regex.
            search: "Something", # String to look for.
            replace: "Replaced" # Replacement value.
        },
        {
            field: "title",
            search: "Something Else",
            replace: "AlsoReplaced"
        }
    ]

#the:
    #the: yes
    #a: yes
    #format: '{0}, {1}'
    #strip: no
#    patterns: []

threaded: yes

paths:
    default: '$genre_fix/%title{$albumartist}/$original_year - $album/%if{$multidisc,Disc $disc/}$track $title'
    albumtype:soundtrack: Soundtracks/$albumartist - $original_year - $album/%if{$multidisc,Disc $disc/}$track $title
    singleton: '$albumartist/$year -  $album/$track $title'
    mis:1: '$albumartist/$year - $album/$track $title'

per_disc_numbering: true

plugins:
    - acousticbrainz
    - artistcountry
    - badfiles
    - cmus
    - convert
    - discogs
    - duplicates
    - edit
    - fetchartist
    - fetchart
    - fromfilename
    - ftintitle
    - fuzzy
    - hook
    - importadded
    - info
    - inline
    - lastgenre
    - mbsync
    - play
    - random
    - replaygain
    - rewrite
    - scrub
    - smartplaylist
    - web
    - wlg

pluginpath:
    - ~/.config/beets/plugins/
    - ~/.config/beets/plugins/bandcamp/beetsplug
    - ~/.config/beets/plugins/airsonic/
    - ~/.config/beets/plugins/fetchartist/beetsplug/
    - ~/.config/beets/whatlastgenre/plugin/beets/beetsplug

# recreated at each run monthly import playlists
smartplaylist:
    relative_to: /export/music/beet_library# as setup on docker container
    playlist_dir: /export/music/playlists
    playlists:
        - name: 'New_%time{$added,%Y-%m}_$genre_no_space.m3u'
          query: 'added:2018-10..' # first month of using beet. monthly playlists will be created afterwards

hook:
  hooks:
    # renaming the "relative_to" part of the playlist created in smartplaylist so this can be used in the airsonic docker container automatically
    - event: cli_exit
      command: "sh -c 'bash /home/lbesnard/bin/beet_playlist_management.sh'"
    - event: import
      command: "sh -c 'bash /home/lbesnard/bin/beet_playlist_management.sh'"

    - event: import
      command: "sh -c 'sh /home/lbesnard/bin/airsonic_update_lib.sh'"

edit:
    itemfields: track title artist album albumartist genre year
    albumfields: album albumartist genre year

importadded:
    preserve_mtimes: yes
    preserve_write_mtimes: yes

play:
    command: mp3blaster --list

replace:
    '[\\/]': _
    '^\.':
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    '\.$': _
    '\s+$': ''
    '^\s+': ''
    '[\xe2\x80\x90]': '-'
    '[\u2010]': '-'
    '‐': '-'
    '’': "'"
    '’': "'"

rewrite:
    artist The Jimi Hendrix Experience: Jimi Hendrix
    albumartist The Jimi Hendrix Experience: Jimi Hendrix
    artist .*Grateful Dead.*: Grateful Dead
    albumartist .*Grateful Dead.*: Grateful Dead
    artist .*Bill Monroe.*: Bill Monroe
    albumartist .*Bill Monroe.*: Bill Monroe
    #albumartist Alt-j: "alt-J"
    #albumartist Alt-j: "alt-J"

path_sep_replace: _

scrub:
    auto: yes

ui:
    color: yes
    text_success: green
    text_warning: yellow
    text_error: red
    text_highlight: red
    text_highlight_minor: lightgray
    action_default: turquoise
    action: blue

# http://akeil.net/listings/beets.config.yaml.html
# Auto Tagger ----------------------------------------------------------------

match:
    strong_rec_thresh: 0.1      # match 90% or better for auto import
    medium_rec_thresh: 0.25
    rec_gap_thresh: 0.25
    max_rec:
        missing_tracks: medium
        unmatched_tracks: medium
    distance_weights:
        source: 2.0
        artist: 3.0
        album: 3.0
        media: 1.0
        mediums: 1.0
        year: 1.0
        country: 0.5
        label: 0.5
        catalognum: 0.5
        albumdisambig: 0.5
        album_id: 5.0
        tracks: 2.0
        missing_tracks: 0.9
        unmatched_tracks: 0.6
        track_title: 3.0
        track_artist: 2.0
        track_index: 1.0
        track_length: 2.0
        track_id: 5.0
    preferred:
        countries: []
        media: []
        original_year: no
    ignored: []
    track_length_grace: 10
    track_length_max: 30

fetchartist:
    cover_name: "folder"
wisp3rwind commented 3 years ago

Fixed in #54, you should upgrade the mediafile package.