Skip to content
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

beets-play: Add the option to pass the "raw" queried pathes to the player command #1578

Merged
merged 6 commits into from
Sep 2, 2015
Merged

Conversation

nathdwek
Copy link
Member

I slightly rewrote the play plugin in order to improve the readability and to introduce the "raw" play config option which makes beet simply pass a list of paths to the play command rather than a playlist.

This possibility is useful because vlc doesn't automatically expand (m3u) playlist files added to the (vlc) playlist (other topics about this issue). Which means that if you intend to use beet play several times in a row, either you have to use the --no-playlist-enqueue vlc option which means that playback will be interrupted, either the temporary playlist created by beets will probably never be read and expanded.

This PR bypasses this issue by simply giving the option to pass the files directly as arguments to the configured command, which in this use-case, allows uninterrupted vlc playback while giving every track its chance to shine (yay!).

For this to work I also had to slightly modify beets.util.interactive_open. I'm quite sure I kept it backwards compatible and the only other call, by beet config -e still works perfecly.

if multiple_targets:
command = command + multiple_targets
else:
command.append(target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future sanity, I think we should just bite the bullet and do the refactoring. That is, there would be only a single way to invoke the function, either with a list-of-strings argument (which can, after all, contain only a single string) or with *args. In either case, we will break backwards-compatibility, but there aren't that many call sites that need fixing. Sound OK?

@sampsyo
Copy link
Member

sampsyo commented Aug 25, 2015

Looks like a great addition! Although I'd like to opt for refactoring over compatibility in this case, if that seems reasonable to you.

@nathdwek
Copy link
Member Author

Seems like some part of the CI failed because github is having response issues.

@nathdwek
Copy link
Member Author

I added a commit to refactor interactive_open so that it can only be invoked with a list of arguments and optionally the command to use. All changes were pretty trivial.

However there's an issue in the existing code: interactive_open does not fork a process: python execution stop at the point of the invocation. The problem is that the function play_music in beets-play does some error catching and cleanup after the player is called, but those actually never happen because of the way interactive_open works. Because of the nature of the operations (catching errors emitted by interactive-open and deleting the temporary playlist, there's no easy way to defer the eventual invocation of interactive-open relative to those two.

@@ -735,7 +735,7 @@ def open_anything():
return base_cmd


def interactive_open(target, command=None):
def interactive_open(targets, command=None):
"""Open the file `target` by `exec`ing a new command. (The new
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring should refer to targets (or perhaps the variable should now be named args or something else generic?).

@sampsyo
Copy link
Member

sampsyo commented Aug 31, 2015

Awesome; this is looking good. Could you please add a description of the option to the docs, at which point we'll merge?

And yes, great point about interactive_open never returning. Let's fix that separately after this is merged. We have two options:

  • Make the play plugin use a different spawning mechanism (leaving interactive_open for config -e and the like).
  • Add an optional flag for interactive_open to avoid execing in place.

@nathdwek
Copy link
Member Author

nathdwek commented Sep 1, 2015

I'm quite busy lately, but documentation and and some makeup should be small enough for me to complete them in the coming days.

It could take me some time however to push the tests both for this PR and #1578. It works with me though if you're willing to merge this even without the tests. I'll just try to be persistent enough to propose them in a following PR.

nath@home added 6 commits September 1, 2015 23:42
I slightly rewrote the play plugin in order to improve
the readability and to introduce the "raw" play config
option which makes beet simply pass a list of pathes
to the play command rather than a playlist.
interactive_open should now be invoked with at least the list of
targets and optionally the command to open the targets with.
This allows beets-play to pass multiple file paths directly to
the configured command.

The changes to the existing invocations are pretty trivial in
order to comply to this refactor.
passed_to_command -> open_args
@nathdwek
Copy link
Member Author

nathdwek commented Sep 1, 2015

Well I just ended up doing it right now.

Everything ok on your side?

@sampsyo sampsyo merged commit b9bc06d into beetbox:master Sep 2, 2015
sampsyo added a commit that referenced this pull request Sep 2, 2015
beets-play: Add the option to pass the "raw" queried pathes to the player command
sampsyo added a commit that referenced this pull request Sep 2, 2015
@sampsyo
Copy link
Member

sampsyo commented Sep 2, 2015

Awesome! Thanks for taking care of this. I added a changelog entry and merged.

And thank you in general for all your contributions lately. I'm adding you as a collaborator in case you see anything you need to maintain directly. Feel free to open PRs still, of course, if you want a code review.

@nathdwek
Copy link
Member Author

nathdwek commented Sep 2, 2015

Thank you very much to you! I'll try to keep it up despite the summer break coming to a close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants