-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fromfilename: Fails to detect <track> <title>
filename patterns
#4561
Comments
Can you please include the filenames you're importing? The |
Folder: 風の国ルイヴェスタ (more exactly, I tried both with underscore "01_[name].ogg" which was the original name, and space "01 [name].ogg") |
Thanks for the extra info! Something does indeed look odd in our beets/beetsplug/fromfilename.py Line 159 in 7cfb55b
However, our patterns appear in this order: beets/beetsplug/fromfilename.py Lines 32 to 33 in 7cfb55b
That is, we try considering the entire filename as just the title first—and only if that doesn't work, we try splitting it into a track number and a title. It really seems like this should go in the other order. If you have a moment, any chance you could give this a try with those two lines swapped? |
<track> <title>
filename patterns
Interestingly, that ordering has been in place for a really long time by now: https://github.com/beetbox/beets/pull/399/files |
Yes, it works with "[\s.-_]<title>" before "<title>". I also noticed the underscore is recognized as valid separator in this pattern, so I tried again with the original file names, and it works (I had to use a custom format to display the track numbers): In the folder containing the tracks: $ beet import .
path/to/unknown_music_tracks (5 items)
No matching release found for 5 tracks.
For help, see: https://beets.readthedocs.org/en/latest/faq.html#nomatch
[S]kip, Use as-is, as Tracks, Group albums, Enter search, enter Id, aBort? u
$ beet ls
- - 深き森にて
- - 緋龍の翼
- - 風の国ルイヴェスタ
- - 終りなき狂詩曲
- - 無慈悲な夜に
$ beet ls -f '$album - $artist - $track : $title'
- - 01 : 深き森にて
- - 02 : 緋龍の翼
- - 03 : 風の国ルイヴェスタ
- - 04 : 終りなき狂詩曲
- - 05 : 無慈悲な夜に So with this, I just need to learn how to apply beet library metadata back to the actual track files, and I should be able to update my music tags very fast! I'll let you have a look whether there are other lines to reorder while we're at it though, and if the reordering won't have bad side effects we didn't think of (isn't there a list of unit tests with dummy track names to test on?) |
Indeed; I can't think of any bad side effects—we should probably just do the reordering! |
I swapped the order of the regex as suggested here and created a draft PR. I would like to take the opportunity to discuss this change and even further improve this plugin. This is what we would have now, skipping the first 3 patterns:
Am I mistaken that the regex |
Another idea I'm testing and actually using day to day for quite a few months already is additional info logging within the plugin: 339aed2 It helps to see what fromfilename is actually doing. Right now it is a blackbox that tries to do good but sometimes even worsens and confuses the search terms. At least with better logging, the user would know that with the messed up tags/filenaming present, there is no chance that beets will find anything anywhere. Let's take an example that occurs to me often. This file has not tags at all and the artistname starts with digits:
The logging is info level because I want it that way. I don't see a point in having to always run beets using -v, the cognitive load is just to high when running longer beets import sessions with I could imagine though that this additional info logging could be enabled with a config directive. I know the output is not pretty right before the importer prompts but it is just very helpful for a user to see why search results are such a mess. |
Taking the logging idea a step further (just for learning how this plugin works) using something like that: JOJ0@cc82852, , we see that with a lot of patterns the number in the artist name is considererd to be the track number:
|
I'm sorry I don't know really where I'm going with this but maybe somewhere around here it could be distinguished that in such a case we shouldn't take the track number as real: https://github.com/beetbox/beets/blob/master/beetsplug/fromfilename.py#L102-L126 Or maybe all the regexes could be more explicitly written to better find out that we have an artist name starting with a digit and it's not the track number. Not sure, but let's leave my proposal as: What do you think about the logging improvement suggestion? #4561 (comment) |
I doubt there's a real solution to the "60 minute man" example within the simple design that this feature currently has: There's no way to distinguish being part of the artist name or the track number, since the plugin only really looks at tracks in isolation. About the logging, I personally wouldn't like this as-is due to interrupting the regular importer UI, as you already note. Maybe let's get this in as debug logs, such that at least this information is available if requested (which already improves upon the current state). Displaying warnings/etc during the import flow is a feature where it'd be really nice to come up with a generic solution (maybe delaying messages until a good point, maybe some terminal control trickery to move them above the current prompt, ...?). I'm not fond of the idea to introduce a configuration option; we already have enough of them to control the actual behavior of beets, let alone to fine-tune logging. |
Thanks for taking the time to think about all this! Looking through these regex patterns again and again I came to a similar thought that it seems not really solveable for artist names starting with digits. I also realised that it's not such of a big deal. Most importantly artist and title are detected correctly, even with the example file from above. Regarding the logging. Thanks as well, I updated the PR. I will remove Draft state when I thint it's ready for a final review. |
Problem
Running this command in verbose (
-vv
) mode:to Use as-is, will led to this problem:
the track numbers are not recognized. For instance, if I run
beet ls
:the track numbers are still part of the files.
If I disable fromfilename plugin, the whole output is empty (no track number nor track name).
Here's a link to the music files that trigger the bug (if relevant):
Use any unknown track, such as a dummy sound file you would create, or rename the folder/files so artist/track cannot be identified (this is however a real use case; I'm simply downloading lesser known tracks from indie bands, etc.)
Setup
My configuration (output of
beet config
) is:Note: write: yes didn't help. In fact, it didn't even seem to change the track names, but that's another issue. I assume
beet ls
alone should show expected information.The text was updated successfully, but these errors were encountered: