beetbox / beets

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

chroma: Fingerprint files on import, even in "as-is" cases #3320

Open gaafiz opened 5 years ago

gaafiz commented 5 years ago

Problem

In short: chroma doesn't apply the audio fingerprint when a track is imported with specific options. Options:

For me is important to have this field for every track to have an additional way to check for duplicates.

Steps to reproduce

  1. Run the beet import command to import a track
  2. After the candidates are shown. select the option Use as-is to import the track
  3. Use beet ls command to check the track just imported (including acoustid_fingerprint in the output format). As alternative you can use the edit with -all option enabled like this
    beet edit --all <track_title>
  4. You will see that the fingerprint is not assigned.
  5. If you choose one of the candidates instead, the fingerprint gets assigned correctly.

(Possible) cause of the issue

I had a look at the code of the importer and the chroma plugin.

workaround

I tried to update the chroma code but I didn't find any better event to use as hook. item_imported was an option but once imported, an item changes the path property necessary for correctly assign chroma metatags in the item.

#Snippet of code from chroma plugin
for item in task.imported_items():
        if item.path in _fingerprints:
            item.acoustid_fingerprint = _fingerprints[item.path]

For eDit and edit Candidates options, I solved customizing the edit plugin triggering the event import_task_apply manually.

# Save the new data.
if success:
    # Return action.RETAG, which makes the importer write the tags
    # to the files if needed without re-applying metadata.
    plugins.send('import_task_apply', session=session, task=task) # <-------- event triggered
    return action.RETAG

An obvious possibility is to run beet fingerprint after every import to be sure to set the fingerprint to every track.

Setup

My configuration (output of beet config) is: No relevant configuration

sampsyo commented 5 years ago

Indeed! The plugin's default mode is really meant to help you match songs to metadata, and of course "as-is" mode won't do that. We can consider this a feature request for an (optional) mode that would do that too.

Furthermore, historically, the interpretation of "as-is" has meant "keep the metadata how it is," i.e., don't add more metadata generated by plugins. We're aware that might not be the best policy—you can find other issues & mailing list discussions that address the idea of running metadata-providing plugins even for "as-is" imports.