beetbox / beets

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

Error trying to merge albums #2588

Open xeals opened 7 years ago

xeals commented 7 years ago

Problem

Trying to merge duplicate albums with beet dup -aM fails. It seems to be an issue with the tiebreaker. If it matters, the duplicate albums don't use ASCII encoding (written in non-Latin language).

Output:

user configuration: /home/amatsu/.config/beets/config.yaml
data directory: /home/amatsu/.config/beets
plugin paths: 
Sending event: pluginload
library database: /media/beets-formatted/library.db
library directory: /media/beets-formatted
Sending event: library_opened
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/beetsplug/duplicates.py", line 158, in _dup
    merge=merge):
  File "/usr/lib/python3.6/site-packages/beetsplug/duplicates.py", line 334, in _duplicates
    objs = self._order(objs, tiebreak)
  File "/usr/lib/python3.6/site-packages/beetsplug/duplicates.py", line 273, in _order
    return sorted(objs, key=key, reverse=True)
  File "/usr/lib/python3.6/site-packages/beetsplug/duplicates.py", line 258, in <lambda>
    key = lambda x: tuple(getattr(x, k) for k in tiebreak[kind])
KeyError: 'albums'

Setup

My configuration (output of beet config) is:

directory: /media/beets-formatted
library: /media/beets-formatted/library.db
plugins: replaygain info embedart fetchart duplicates badfiles the missing
          mpdstats smartplaylist mbsubmit lastgenre

# substitution options
replace:
  '[\\/]': _        # bask/forward slash
  '^\.': _          # leading period
  '[\x00-\x1f]': _  # control characters
  '[<>:"\?\*\|]': _ # Windows reserved
  '\.$': _          # trailing period
  '\s+$': ''        # consecutive whitespace
  '^\s+': ''        # leading whitespace
  '[“”]': '"'       # typographical quotes
  # '[\x91\x92\u7e2\u7e3]': "'"

ui:
  color: yes

# import
import:
  write: yes
  copy: yes
  resume: ask
  incremental: yes
  log: /media/beets-formatted/import.log
languages: jp en
match:
  preferred:
    countries: ['AU', 'US', 'JP']
    media: ['CD', 'Digital Media|File', 'Vinyl']
    original_year: yes

# naming
paths:
  default: %the{$albumartist}/$album/$track $title
  singleton: %the{$albumartist}/Other/$title
  comp: Compilation/$album/$track $title
  albumtype:soundtrack: Soundtracks/$album/$track $title

# replaygain
replaygain:
  auto: no
  backend: gstreamer

fetchart:
  auto: yes
  sources: filesystem coverart amazon wikipedia albumart itunes google
embedart:
  ifempty: no
  auto: yes
thumbnails:
  auto: yes
mpd:
  host: localhost
  port: 6600

duplicates:
  tiebreak:
    items: [bitrate]
sampsyo commented 7 years ago

Thanks for reporting! To help narrow things down, does the problem go away if you turn off your tiebreak setting?

Assigning to @pedros, the original author and current expert on the duplicates plugin.

xeals commented 7 years ago

Error does indeed go away without the tiebreak setting, but it seems like it doesn't properly merge the albums, as beet ls -a <album> still gives two results.

Might also be worth mentioning that (presumably) because it won't merge albums, beet dup -d removes everything in the duplicate album, rather than just tracks that are also in the first album.

For a bit more information, if it helps, I have an album in both FLAC and MP3, but the FLAC album isn't complete, and I want to fill in blanks with the MP3 versions.

sampsyo commented 7 years ago

That makes sense! Thanks for the detailed report; I hope @pedros can help shed some light on the underlying problem.

etetlow commented 7 years ago

I was getting the same error and found that using the syntax tiebreak: { items: [bitrate] } works.