-
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
Set field values on the import command line #1881
Comments
Thanks! I'm in favor of this feature. I could have sworn we'd discussed this before, but I can't find any other issues about it (#565 discusses something vaguely similar). Perhaps it was on the mailing list? |
I never read the ML, so I have no clue whether it has been been proposed before. Maybe #488? |
Yeah, that's also related. Well, I'm glad we have an issue now! |
I would totally love this feature too. I have thousands of artists and the way beets stores by default is great, but generates a ton of directories (one for each artist). This makes it impractical (for me anyway) to look for media when browsing, and causes long delays over network shares (CIFS sends all the folder names at once). Being able to arbitrarily split the library some more (by genre or otherwise) allows to break this down more and I feel this is critical for people with a large library. |
@acastaner any existing metadata (not just artist) can be used for path configuration, cf https://beets.readthedocs.org/en/v1.3.17/reference/config.html#path-format-configuration bucket plugin can be of some use to resolve your problem of network delay due to huge folder listings. |
Mostly my need (and what this feature request is about) is to set the field value upon import. This way it's not required to "pre-tag" the library we want to import, or manually tag after import. For instance my beets is setup so that anything with the "savedir" field with value "metal" goes to the "metal_hard-rock" directory. But beets will act on this only through the mod command, not import. So I have to import everything then manually beet mod all the files. Not practical. If we could do it upon import then that issue is solved because the operation happens onthe specified directory not through filters/queries. I hope I'm clear and making sense :-) On Sun, Apr 17, 2016 at 1:40 PM -0700, "Fabrice Laporte" notifications@github.com wrote:
@acastaner any existing metadata (not just artist) can be used for path configuration, cf https://beets.readthedocs.org/en/v1.3.17/reference/config.html#path-format-configuration bucket plugin can be of some use to resolve your problem of network delay due to huge folder listings. You are receiving this because you were mentioned. |
Hi, |
Awesome! I'm glad you're interested in helping. The right place to start is with the configuration handling in Eventually, the feature should probably work via a configuration option that adds the attribute in the importer stage that applies the metadata from a match. |
I suggest to implement this as follows: First, we add an optional argument to import that takes multiple field=value arguments like this: |
Yes; this sounds great! I completely agree it should live in the Details on the interface:
|
Just wondering how's the progress @tissieres ? Really just can't wait for that feature! I don't really write Python but I could help you test if you need |
Did not have much time to work on it, but it's still on my todo list... |
I am 100℅ in favour of this. Some of my music has a |
@sampsyo I have begun trying to implement the ability to add options to subcommands via Plugins as mentioned in #2567. It seems to work, but I want to make sure I'm not underestimating things here, especially since you mentioned the probable need for a new CLI parsing library which I didn't use. Basically what I did is:
At a first glance this seems to work. Could you please give me some feedback? I'm a little insecure because of my lack of experience, so this feels like a great oppertunity to learn! If you think this sounds good, I'm going to look into part two of the story: accessing those new CLI options/arguments of these subcommands from a plugin, so they can be put to use instead of simply being CLI-candy (see what I did there? ;)). |
Thanks for looking into this. Regardless of the specific design, though (which looks good!), I'm still a little nervous about the fundamentals: this basically ties us to use optparse forever, instead of an eventual switch to Click or another, more modern option-parsing library. (See #2190 and #1484, for example.) Giving all plugins access directly to the Is there any chance we should just direct this effort toward the original goal of this ticket, which is just one new flag that lets you set fields for the |
Thanks for your feedback. And funny you should mention: I actually tested adding custom options to subcommands provided by plugins, because I was also a bit weary about it. Anyhow, I was unaware of the longterm plans of phasing out Good point, I'll look into that instead. Again thanks for your feedback, this is really educational for me :). |
Actually, if my digging is accurate, it seems not be a suitable place after all. The if task.apply:
task.apply_metadata()
plugins.send('import_task_apply', session=session, task=task) I verified this by noticing that when I passed How about an extra stage, say PS My guess for the reason why it imports the metadata anyways is because of the transaction at the bottom of the |
Aha, good point. You're right that apply_metadata won't quite do for imports that wouldn't otherwise apply metadata. An additional import stage would totally work; or we could tie the update onto the "finalize" stage. (You're right that the file-manipulation stage updates the database just to store new paths when the copying/moving has finished, which won't affect album structures.) As alternative, a more complex design could avoid extra transactions by changing the metadata before it ever reaches the database in non-autotagged mode, or by changing it right after applying metadata when using a match, or by falling back to a separate transaction when the user chooses "as-is". But that's probably premature optimization. 😃 |
Regarding the Personally I think choosing to add this to the finalize stage is concealing and sacrifices separation of concerns for simplicity. An additional import stage feels neater, wouldn't you say? I'm not sure I follow entirely. One thing for me to grasp here I think is: is it desired to sync to the db after updating the models, or should this be taken care of by the transaction near the end of the import process (in file manipulation stage for instance, which kind of repeats my first question as to the intended behavior of its transaction)? I'm confused when syncs to the db occur, it doesn't seem to be consistently after each metadata operation, nor after all of them in a single sync (which could reside in Thank you! |
It's coming along nicely! Parsing the arbitrary amount of field/value pairs like Am I missing a way of doing this here?
I'd go with method 1, but be sure to let me know your ideas! |
Yeah, the intention is just to save the new paths there. Of course, we don't currently have a way to update one field at a time, so it has the side effect of syncing all the metadata. Other metadata actually has other places where it's synced. First, all the initial metadata for all imports is added to the database in So, I totally agree that finalize is the wrong place, but how about |
And yeah, good point about the complexity of parsing the CLI options. I somewhat strongly agree with out about preferring this option:
In addition to being easier to parse, I also like it better from a UI perspective! It avoids violating people's expectation that flags look like |
Ah, of course, I overlooked the fact that
Another thing I bumped into: should field/value pairs supplied at the CLI be appended to the ones specified in the config block, or override them? In the case of appending it's especially interesting if you define the same field in both places, in which case the user might expect both values to be aggregated and written as a multivalue (even though those aren't supported yet, right?), but in fact the CLI value will overwrite the config one. Finally: I've read the "Testing" section in the wiki, but I think I need some help. Is the IRC channel a good place to look? Sorry for all the questions; it's my first open-source contribution. |
Yeah, I think I do like the idea of using That's a good question about the config/CLI composition. I suppose I don't have a strong opinion—but perhaps the most logical thing would be to append the CLI settings onto the config settings, so the user does have the option to override the config if they want to. Yeah! IRC (or Discourse, or here) is absolutely a good idea for questions about the tests. And no problem! Answering questions is what we're here for. |
Okay, I think I'm done with everything except the tests. I asked help via IRC and I think I know where to start. I still have a few questions though:
And as far as checking for valid input goes, I could implement a custom optparse type named something like Thanks again. |
Great! I'm glad IRC was helpful. If you learned anything that you think would also help other newcomers, would you mind adding it to the testing wiki page? That would be awesome!
For validation, I think a reasonable strategy would just split on =, and if there's no = in the string, just raise a UserError (out exception for user-visible errors). It might even be useful to reuse the parsing logic from the |
I believe I'm done :). It seems to work fine! |
Great! Yes! I'll leave comments on the pull request. |
Set field values on the import command line #1881
Thanks @bartkl! |
Is the final command --set-field x=y (as detailed in this discussion) or --set x=y (as detailed in the release notes) ? E: It's as per the release notes, just checked better :) |
So I've just tried this feature in details in beets 1.4.5 and it doesn't seem to behave completely as I expected (could be that my expectation was wrong). Maybe my usage is a bit of corner case. I like to sort my music by directories named after the style of music in them. So I have "ost", "classical", "metal" and so on. In order to tell beets where to move the files I setup a specific configuration in
So (mostly) based on the "savedir" flexible attribute beets knows where to put my music. So far I was settings this by hand using Now that my use case is hopefully clear I should explain my expectation. I was expecting that when doing something like But this is not what happens ; beets imports fine but doesn't move the files. It does however add the flexible attribute, so when I try to manually trigger the change like before by using Is there a way to change this behavior? Am I in some kind of edge case? |
Hmm! We should totally support this use case; it's clearly part of the utility of the new option. I can imagine two problems: paths are determined before we set the fields; or some problem with album-level vs. item-level fields. To check this, can you see whether running |
I'm interested in this case too. But I was wondering: can't one just use
|
Hey there, Am I doing something wrong? |
The fields are set on the album, not the single tracks inside it. |
Thank you, I didn't know that! Can I use them like the fields in advanced awesomeness? |
No clue. But even if not, you should manually apply your album-tags to contained tracks and then use those values. |
Hey there, i know this is closed, but wouldnt it be nice to have --set actually work on tracks fields instead of just albums? |
What are you trying to achieve? Might that already be solved by #2988? Otherwise, if there's still a use-case for this, I guess someone would need to come up with a design for how to build the CLI and configuration for setting album-fields. |
Usage:
beet import --explicit-field context=party --explicit-field category=disco some_folder
I have different categories of music which I don't want to mix. For this is would be useful to be able to specify explicit metadata on import.
The text was updated successfully, but these errors were encountered: