-
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
mbsubmit: Add picard PromptChoice
#4807
Conversation
Hi, interesting idea. Why not make the tag-editor configurable? Me personally I prefer puddle-tag or mp3tag (on macOS) over Picard when tags are so bad that beets alone is not sufficient. |
The point of opening Picard is not for tagging the files of the release, but to read the already tagged files and open a 'add release' page in musicbrainz' website, that will include most of the information needed for a proper release entry in the database. Then, once it's in the database, you continue the import process, using the release id you got from musicbrainz, and beet tags the files for you. |
Oh I see! That is indeed a cool feature!! |
Is it possible for us to link directly to the release creation page on MusicBrainz (with the fields pre-filled) instead of doing it via Picard? |
That is the idea suggested in #1866 . It's a great idea, but it's much harder to implement. See my comment there linking picard's relevant source code. |
Short of being able to directly add information to MB, using Picard seems like a nice middle ground. Looking forward to this 👍 |
@doronbehar can you resolve the conflicts so that we can move forward with this? |
2d248c7
to
c0b2b84
Compare
Fixed merge conflicts via a rebase. |
Hmm not sure why CI says my order of imports is incorrect... |
Use |
c0b2b84
to
8ab7b58
Compare
Done! |
8ab7b58
to
aabffa3
Compare
Fixed |
There are still a couple minor lint errors. |
aabffa3
to
4ab75d3
Compare
Thanks for help. Hopefully it'll be green now. |
4ab75d3
to
64ee313
Compare
b5f6526
to
0be2382
Compare
Added docs and a changelog line. |
test/plugins/test_mbsubmit.py
Outdated
@@ -61,7 +61,7 @@ def test_print_tracks_output_as_tracks(self): | |||
self.importer.run() | |||
|
|||
# Manually build the string for comparing the output. | |||
tracklist = "Print tracks? " "02. Tag Title 2 - Tag Artist (0:01)" | |||
tracklist = "Print tracks," "02. Tag Title 2 - Tag Artist (0:01)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably revert this change
0be2382
to
dd01254
Compare
I don't understand how that test passed... The error now, from CI is:
I changed it now to something which might work. |
7d51f25
to
d097d5a
Compare
242ca2d
to
4ab2d50
Compare
Agree with everything, work away :-) |
0aefd22
to
2d3c181
Compare
Thanks for the cooperation, and again sorry for the slow replies :). I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. No worries about response times. We are getting there! :-) One question within.
beetsplug/mbsubmit.py
Outdated
def picard(self, session, task): | ||
picard_path_orig = self.config["picard-path"].as_filename() | ||
picard_path = which(picard_path_orig) | ||
if picard_path is None: | ||
if picard_path_orig.startswith("/"): | ||
self._log.error( | ||
"picard-path defined in config at\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I still don't quite understand this part. Can you explain what the indented functionality is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I still don't quite understand this part. Can you explain what the indented functionality is?
It's OK :) I updated this section with 2 more comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm still I don't understand why we need that much logic to try running a path that's configured by the user anyway.
Simplification suggestion:
remove the which(),
just check if what the user configured looks like a path (you did that using confuse's path function, perfect)
just try running and fail gracefully. that's the way other beets plugins run external programs too.
I think with this conversation we decided on that approach: #4807 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a simplified version of like the play plugin does it. A try/except block using subprocess.call
and then fail gracefully if that doesn't work out?
Lines 50 to 58 in 951b0f5
try: | |
if keep_open: | |
command = shlex.split(command_str) | |
command = command + open_args | |
subprocess.call(command) | |
else: | |
util.interactive_open(open_args, command_str) | |
except OSError as exc: | |
raise ui.UserError(f"Could not play the query: {exc}") |
or maybe use util.interactive_open()
not sure which way is more appropriate here. you choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a simplified version of like the play plugin does it.
Thanks for the link :) I used it as a reference, though haven't tested in an environment with no picard available or so..
using subprocess.call
Is there an insistence on subprocess.call and not subprocess.Popen? Python describes call as an older-level API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, goot catch. then use .Popen. sounds good.
I've always used subprocess.run in the past. not sure if that makes sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I accidantly edited your post above, I hope I restored it correctly!
PromptChoice
sPromptChoice
445a963
to
d38ef97
Compare
It'd be nice if someone else will give this PR a test drive on a machine without |
could be easily done by yourself, by just providing a non-existent path in the config: confuse's when you try running with subprocess.Popen, your error should be catched and handled by the except clause. So just to clarify and prevent further misunderstandings, what I think would be the most straight forward way and will work on all platforms and can be tested easily by yourself:
please doublecheck my assumption about edit: But I can certainly test it out on my machine were currently is no Picard installed, once you are finished with implementing. |
You are right :) I wasn't thinking about it. Here's what I added to my config for testing: mbsubmit:
picard-path: picard-missing
And I got the following experience:
And the Here is the behavior I get with an implementation similar to the previous - using
Also note, that the import process doesn't stop completely when failing to run
Sure :) now that I learned to test it, I'll notify you when I'm satisfied with the behavior. I pushed (without
|
Hi, you are right using as_filename() might not be the best choice here. My impression was that as_filename() checks for an absolute path and errors if that's not the case. The magic it does with relative paths is not what we want here. Sorry I should have read docs more closely. My idea actually was that it should be required for a user to always configure an absolute path since I've not seen automatic retrieval of paths for external programs in other places in beets. I might be wrong. I still think it's sufficient and most safe if we don't put too much magic here since we can't test on all platforms. which() works on Windows too as far as I read in the docs, but the executable will probably be could picard.exe or something. So the default of Because uf exiting: You don't have to raise another exception, you could just print the error using Your current code looks much better now. My main problem with it was probably the cascaded if conditions and especially the check for `....startswith("/") - it was just hard to read what's going on here. That's why I suggeste a simple try/except. What do you think of something like that:
(or something similar including the usage of which()) Error looks like that and beets stays alive:
One more thing: Please rename the config option to not include dashes: |
For decoding paths there is a utility in
|
a2e8db5
to
991d542
Compare
Thanks for all the suggestions! I liked even more the behavior with the
I agree. Additionally, you should remember that even if a user installs picard and get a |
Make it possible to open picard from the import menu when there are weak recommendations.
991d542
to
615caae
Compare
Awesome, code looking perfect now. Some nitpicking on the docs: Maybe state that picard path needs to be configured. |
615caae
to
9357448
Compare
Great :) I just installed Picard on a Windows platform and amended a sentence to the |
That help now reads very complete and I think it tells everything one needs to know on how to use these new features. Thanks a lot. I'm happily merging this now. At this point: Thanks a lot for baring with us with those loads of iterations and refinements. Often it is not so easy for all participants to see the most straight-forward way for a feature/plugin. After all I personally think it was worth it that we didn't rush a merge and thanks again for your patients and the good work! :-) |
Sorry for replying so late.
I (and I imagine a lot of other users) use beets on headless machines (over SSH), which don't really have the option for using It feels to me like the behaviour should be:
|
Hi @jackwilsdon, I just saw your comment about headless machines. We didn't take this interesting thought into account yet, I might have missed this perspective in our previous conversations. Please could you open a feature request issue for that? I think it won't be hard to implement. Then let's move all the discussion on how it should work over there. Sorry again I missed this part and thanks in advance! |
I'm also a bit surprised that headless machines were a strong reason in favor of hiding the Picard prompt choice... we talked about it long ago and I got the impression that we settled down upon not hiding it. I am also a bit surprised though that users of headless machines even use the The logic @jackwilsdon suggested looks not bad, and I haven't thought about it myself back when we discussed this detail. However, I still think that having this |
The
From how many people use the LinuxServer.io Docker image (over 10M pulls, although this seems quite inflated), I'd say there's probably a decent number of people using beets without a desktop environment. It's not that it's really an inconvenience, it just seems less than ideal to be showing an option that we know will throw an error. I'm not overly bothered by it at the end of the day (not enough to open a feature request), it just seemed like it'd be nice if we didn't show an extra prompt choice if we didn't need to (as there's already a good number of choices). |
Make it possible to open picard from the import menu when there are weak recommendations. Add another menu option to print the tracks into a beets-unmatched file for later parsing.
Description
A better alternative to #4749 - closes #4749 . Also provides an intermediate solution to #1866 .
cc @ybnd .
To Do
docs/
to describe it.)docs/changelog.rst
near the top of the document.)test_mbsubmit.py
was modified to accommodate the change.