beetbox / beets

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

zero: Removing images despite whitelisting images #3532

Open agross opened 4 years ago

agross commented 4 years ago

Problem

Hello! New beets user here. Awesome project, thank you for creating it!

I run beets with the zero plugin in whitelist mode. I want to keep only a couple of metadata fields, including cover art.

Running this command in verbose (-vv) mode:

# The file contains a cover image 
$ eyeD3 /beets-test/Kontor Sunset Chill 2018/Kontor Sunset Chill 2018 CD 3 - 10 - Be Svendsen - Andromeda.mp3
ID3 v2.3:
title: Andromeda
...
FRONT_COVER Image: [Size: 171538 bytes] [Type: image/jpeg]

# Write metadata
$ beet -vv write andromeda
user configuration: /Users/agross/.config/beets/config.yaml
data directory: /Users/agross/.config/beets
plugin paths:
Sending event: pluginload
artresizer: method is (2, (7, 0, 10), False)
inline: adding item field maybe_disc
inline: adding item field maybe_soundtrack
library database: /Users/agross/Downloads/beets.db
library directory: /Users/agross/Downloads/beets-test
Sending event: library_opened
/beets-test/Kontor Sunset Chill 2018/Kontor Sunset Chill 2018 CD 3 - 10 - Be Svendsen - Andromeda.mp3
  tracktotal: 00 -> 20
  disctotal: 00 -> 03
  comp: False -> True
  mb_trackid:  -> 12171320-3-10
  mb_albumid:  -> 12171320
  mb_artistid:  -> 2282919
  mb_albumartistid:  -> 194
  albumtype:  -> Compilation, Mixed
  label:  -> Kontor Records
  mb_releasegroupid:  -> 0
  catalognum:  -> 1069674KON
  country:  -> Germany
  media:  -> CD
  disctitle:  -> Miami Sundowner Mix
  original_year: 0000 -> 2018
Sending event: write
zero: genres:  -> None
zero: genre:  -> None
zero: lyricist:  -> None
zero: composer:  -> None
zero: composer_sort:  -> None
zero: arranger:  -> None
zero: grouping:  -> None
zero: tracktotal: 20 -> None
zero: disctotal: 3 -> None
zero: lyrics:  -> None
zero: comments:  -> None
zero: bpm: 0 -> None
zero: comp: 1 -> None
zero: albumtype: Compilation, Mixed -> None
zero: label: Kontor Records -> None
zero: artist_sort:  -> None
zero: albumartist_sort:  -> None
zero: asin:  -> None
zero: catalognum: 1069674KON -> None
zero: disctitle: Miami Sundowner Mix -> None
zero: encoder:  -> None
zero: script:  -> None
zero: language:  -> None
zero: country: Germany -> None
zero: albumstatus:  -> None
zero: media: CD -> None
zero: albumdisambig:  -> None
zero: date:  -> None
zero: month: 0 -> None
zero: day: 0 -> None
zero: original_date:  -> None
zero: original_year: 2018 -> None
zero: original_month: 0 -> None
zero: original_day: 0 -> None
zero: artist_credit:  -> None
zero: albumartist_credit:  -> None
zero: art:  -> None
zero: mb_trackid: 12171320-3-10 -> None
zero: mb_releasetrackid:  -> None
zero: mb_albumid: 12171320 -> None
zero: mb_artistid: 2282919 -> None
zero: mb_albumartistid: 194 -> None
zero: mb_releasegroupid: 0 -> None
zero: acoustid_fingerprint:  -> None
zero: acoustid_id:  -> None
zero: rg_track_gain: None -> None
zero: rg_album_gain: None -> None
zero: rg_track_peak: None -> None
zero: rg_album_peak: None -> None
zero: r128_track_gain: None -> None
zero: r128_album_gain: None -> None
zero: initial_key: None -> None
Sending event: after_write
importadded: Write of item '/beets-test/Kontor Sunset Chill 2018/Kontor Sunset Chill 2018 CD 3 - 10 - Be Svendsen - Andromeda.mp3', selected item.added=1536234269.0
Sending event: database_change
Sending event: cli_exit

Led to this problem:

$ eyeD3 /beets-test/Kontor Sunset Chill 2018/Kontor Sunset Chill 2018 CD 3 - 10 - Be Svendsen - Andromeda.mp3
...
ID3 v2.3:
title: Andromeda
artist: Be Svendsen
album: Kontor Sunset Chill 2018
album artist: Various Artists
recording date: 2018
track: 10
disc: 3

The important bit seems to be zero: art: -> None in the output of beet write. This field isn't reported in beet fields, just like image.

Workaround

Add art to zero.keep_fields.

Setup

My configuration (output of beet config) is:

directory: /beets-test
library: ~/beets.db

import:
    copy: yes
    move: no
    write: no

replace:
    ':': ' -'
    \?: ''
    '[\\/]': _
    ^\.: _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    \s+$: ''
    ^\s+: ''

paths:
    default: $albumartist - $album%aunique{}/$albumartist - $album$maybe_disc - $track - $artist - $title
    comp: $album%aunique{}$maybe_soundtrack/$album$maybe_soundtrack$maybe_disc - $track - $artist - $title
    singleton: $artist - $title
per_disc_numbering: yes
id3v23: yes

format_item: $path
format_album: $path
art_filename: cover

plugins:
- importadded
- ftintitle
- zero
- badfiles
- discogs
- inline
- info
- fetchart
- embedart
item_fields:
    maybe_disc: u' CD %i' % (disc) if disctotal > 1 else u''
    maybe_soundtrack: u' O.S.T.' if albumtype == 'soundtrack' else u''
importadded:
    preserve_mtimes: yes
    preserve_write_mtimes: yes
fetchart:
    auto: yes
    cover_names: [cover, front]
    sources:
    - filesystem
    - amazon
    - coverart
    - itunes
    - albumart
    - wikipedia
    - google
    minwidth: 0
    maxwidth: 0
    enforce_ratio: no
    cautious: no
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    store_source: no
embedart:
    auto: yes
    ifempty: yes
    maxwidth: 2000
    remove_art_file: no
    compare_threshold: 0
zero:
    auto: yes
    update_database: no
    keep_fields:
    - albumartist
    - artist
    - album
    - disc
    - track
    - title
    - year
    - images
    fields: []
ftintitle:
    auto: yes
    drop: no
    format: feat. {0}
pathfields: {}
album_fields: {}
discogs:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    user_token: REDACTED
sampsyo commented 4 years ago

Thanks for pointing that out! FWIW, the underlying problem is that MediaFile exposes images in two different ways: https://github.com/beetbox/mediafile/blob/8846cdf226ee61ec181b03f0133046bc37cebd3d/mediafile.py#L1893-L1897

I think the expedient way to address the problem is to amend the docs to recommend including both images and art, as ugly as that seems. We could also consider "aliasing" one to the other as a special case in the plugin.