beetbox / beets

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

wrong file order when importing untagged files #3667

Closed the-confessor closed 4 years ago

the-confessor commented 4 years ago

I've run into an issue a handful of times when importing a set of completely untagged files.

I run a beets import, provide a MusicBrainz release ID, but Beets appears to not be able to figure out how to order the files.

The files will be named such that, when sorting alphabetically, they appear in the same order as on the release.

In some cases of multi-disc releases I have tried keeping all the files in one folder, as well as creating one subfolder per disc, and the results are the same.

A specific example that I have not found a practical workaround for -

Importing this release, the first few lines of the preview we immediately see a track mis-match:

$ beet import -S 2addef1b-9ce4-489f-834c-07ce58bf5bb8 Oasis--Whats-The-Story-Morning-Glory

/media/inbox/music/purchased/Oasis--Whats-The-Story-Morning-Glory
/media/inbox/music/purchased/Oasis--Whats-The-Story-Morning-Glory/CD 1
/media/inbox/music/purchased/Oasis--Whats-The-Story-Morning-Glory/CD 2
/media/inbox/music/purchased/Oasis--Whats-The-Story-Morning-Glory/CD 3 (40 items)
Correcting tags from:
    (unknown album)
To:
    Oasis - (What’s the Story) Morning Glory?
URL:
    https://musicbrainz.org/release/2addef1b-9ce4-489f-834c-07ce58bf5bb8
(Similarity: 39.2%) (tracks, album, artist) (3xDigital Media, 2014, XW, Big Brother Recordings)
Digital Media 1
 * 01_01_Hello.mp3 (#0)                                   -> Hello (#1) (title)
 * 03_13_Cast No Shadow (Live At Maine Road).mp3 (#0)     -> Roll With It (#2) (title)

For some reason here it is trying to map track 13 of disc 3 into track 2 of disc 1. This is just the first example - the import is full of similar mis-matches.

I have confirmed that the files are named correctly. Track 13 of disc 3 and track 2 of disc 1 are not even the same length.

I'm a little puzzled about how beets is choosing the order to import these files. Alphabetical order seems like it would be an intuitive thing to do. Even matching by track length alone would get a more accurate import than I am seeing.

Can anyone provide any insight? Any suggested workarounds?

sampsyo commented 4 years ago

By default, beets uses files' metadata to align tracks. (The metadata includes track lengths, but those can vary to a suprirrisng degree and are somewhat unreliable alone.) It works by trying to find the minimum-cost matching in a bipartite graph formed by your current tracks the the data from MB. When you don't have any metadata, the assignment algorithm doesn't know what to do and behaves unpredictably.

Perhaps notably, it does not use filenames at all by default. To that end, have you tried the fromfilename plugin, which can (if you're lucky) guess some metadata from filenames?

the-confessor commented 4 years ago

I will look into the fromfilename plugin as a workaround. I could also try using the acoustic fingerprinting plugin, though I was having trouble getting that working last I tried.

If the assignment algorithm behaves unpredictably for untagged files would it make sense to take a different approach for untagged files? Sorting the files alphabetically then aligning them to tracks based on index may not always be correct, but at least it is predictable.

sampsyo commented 4 years ago

Perhaps. It's a little harder than it seems, however, because we don't currently have any representation of a state that means "untagged files," and it would take significant plumbing to mark music that is truly devoid of tags and handle them with a completely separate matching strategy.

the-confessor commented 4 years ago

Good to know. I will explore workarounds, then.