beets icon indicating copy to clipboard operation
beets copied to clipboard

badfiles: Respect "quiet" mode during import hook

Open simonmcnair opened this issue 1 year ago • 8 comments

Error:

BAD one or more files failed checks:
/srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/forbeets/Albums/aaa/bbb/Verified/flac/ccc.flac: checker exited with status 1
  bbb.flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
  *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
  *** Got error code 1:FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER
  *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
  bbb.flac: ERROR while decoding data
                 state = FLAC__STREAM_DECODER_ABORTED

What would you like to do?
a[B]ort, Skip, Continue?

command line:

/usr/local/bin/beet -vvv import /srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/forbeets

Config

plugins: fetchart embedart convert scrub replaygain lastgenre chroma lyrics fromfilename info badfiles ftintitle inline duplicates hook albumtypes smartplaylist missing
directory: /srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/sorted
library: /srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/beetsmusiclibrary.blb
art_filename: albumart
threaded: yes
original_date: no
per_disc_numbering: yes
ui:
    color: yes
    colors:
        text_success: green
        text_warning: yellow
        text_error: red
        text_highlight: red
        text_highlight_minor: lightgray
        action_default: turquoise
        action: blue
convert:
    auto: no
    ffmpeg: /usr/bin/ffmpeg
    opts: -ab 320k -ac 2 -ar 48000
    max_bitrate: 320
    threads: 1
#paths:
#    default: $albumartist/$album%aunique{}/$disc-$track $title
#    default: $albumartist/$album%aunique{}/$track - $title
#    singleton: Non-Album/$artist - $title
#    comp: Compilations/$album%aunique{}/$track - $title
#    albumtype_soundtrack: Soundtracks/$album/$track $title

match:
    required: artist album
    max_rec:
        missing_tracks: strong
        unmatched_tracks: strong
    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
    ignored: missing_tracks unmatched_tracks
    strong_rec_thresh: 0.75    # Reflects the distance threshold below which beets will make a “strong recommendation” that the metadata be used.
                             # Strong recommendations are accepted automatically (except in “timid” mode),
                             # so you can use this to make beets ask your opinion more or less often.
                             # The threshold is a distance value between 0.0 and 1.0, so you can think of it as the opposite of a similarity value.
                             # For example, if you want to automatically accept any matches above 90% similarity, use: "strong_rec_thresh: 0.10"
                             # The default strong recommendation threshold is 0.04.
                             # When a match is below the medium recommendation threshold
                             # or the distance between it and the next-best match is above the gap threshold,
                             # the importer will suggest that match but not automatically confirm it.
                             # Otherwise, you’ll see a list of options to choose from.

    medium_rec_thresh: 0.125   # The medium_rec_thresh and rec_gap_thresh options work similarly.
paths:
    default: Albums/$albumartist/[$year]$atypes $album/$disc-$track $title
    albumtype:soundtrack: Various Artists/$album [$year]$atypes/$disc-$track $title
    comp: Various Artists/$album [$year]$atypes/$disc-$track $title
    singleton: Non-Album/$artist - $title
import:
    write: yes
    copy: no
    move: yes
    resume: yes
    incremental: yes
#    incremental: no
    quiet_fallback: skip
    timid: no
    log:  /srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/beet.log
#    quiet: no
    quiet: yes
    none_rec_action: skip
    default_action: apply
    duplicate_action: keep
    group_albums: yes
duplicates:
    move:   /srv/dev-disk-by-uuid-342ac512-ae09-47a7-842f-d3158537d395/mnt/Audio/Dupes/
    checksum: ffmpeg -i {file} -f crc -
    count: yes
#    checksum: ''
item_fields:
    multidisc: 1 if disctotal > 1 else 0
    decade: str(year)[0:3]+"0s"
lastgenre:
    auto: yes
    source: album
embedart:
    auto: yes
fetchart:
    auto: yes
replaygain:
    auto: no
scrub:
    auto: yes
replace:
    '^\.': _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    '[\xE8-\xEB]': e
    '[\xEC-\xEF]': i
    '[\xE2-\xE6]': a
    '[\xF2-\xF6]': o
    '[\xF8]': o
    '\.$': _
    '\s+$': ''
albumtypes:
    types:
        - ep: 'EP'
        - single: 'Single'
        - soundtrack: 'OST'
        - live: 'Live'
        - compilation: 'Anthology'
        - remix: 'Remix'
        - album: 'LP'
    ignore_va: compilation
    bracket: '[]'
badfiles:
    check_on_import: yes
    mp3: mp3val
    flac: flac --test --warnings-as-errors --silent
    m4a: ffprobe -v error
lyrics:
    auto: yes

simonmcnair avatar Mar 29 '23 14:03 simonmcnair

That's interesting! I admit I'm not a user of badfiles, so I'm not intimately familiar with the expected behavior here. In a quiet import, it is indeed the case that we're not supposed to prompt—we just forge right ahead with an assumed action. Can you explain a little bit about how you would like this to work? What should the quiet-mode importer do when this plugin is enabled and does/does not find a problem in the files it's importing?

sampsyo avatar Apr 01 '23 22:04 sampsyo

That's interesting! I admit I'm not a user of badfiles, so I'm not intimately familiar with the expected behavior here. In a quiet import, it is indeed the case that we're not supposed to prompt—we just forge right ahead with an assumed action. Can you explain a little bit about how you would like this to work? What should the quiet-mode importer do when this plugin is enabled and does/does not find a problem in the files it's importing?

I would expect badfiles to run silently through the entire library and then for the results only to be available via 'beets bad' I would expect that to always be the case imo. Hoever I also believe that all plugin prompts for all plugins should be suppressed if quiet is set to yes. Perhaps this is an enhancement. Otherwise this could cause multi threading issues (possibly) where all the threads are tied up waiting for input but the console could, possibly, be unintelligable from console lines being overwritten or passing beyond the screen/buffer.

I hope this makes sense.

simonmcnair avatar Apr 02 '23 07:04 simonmcnair

Yes, it does! I've marked this as a bug. When it runs as an import hook, the plugin should probably not print anything and it should definitely not prompt for input.

sampsyo avatar Apr 07 '23 18:04 sampsyo

I'm guessing this requires a modification to the plugin architecture ? so that it applies to all plugins ? I wonder what would happen if something requires input to continue and has no skip ability ?

simonmcnair avatar Apr 12 '23 13:04 simonmcnair

I don't think so—it seems inevitable that this will be on a plugin-by-plugin basis (so they can bring their own notion of what "quietness" means, i.e., what they should do by default when the user can't provide input). So the badfiles plugin just needs to check the quiet flag and act accordingly.

sampsyo avatar Apr 12 '23 14:04 sampsyo

Is that not asking for bugs to be raised if they don't respect the quiet flag ? It would seem better to handle this at a higher level, or enforce at plugin level ?

simonmcnair avatar Apr 12 '23 18:04 simonmcnair

Yes, it is indeed inviting bugs to be filed if the plugins don't respect the flag. Unfortunately, I think this is the only way to do it because the plugin's logic in quiet mode is very plugin-specific.

We already do some of the "generic" thing with logging, i.e., log.info has a different effect when the plugin is run "alone" vs. as part of the import pipeline.

sampsyo avatar Apr 12 '23 18:04 sampsyo

Really no comments on the PR ?

simonmcnair avatar Nov 20 '23 09:11 simonmcnair