beetbox / beets

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

Allow play plugin to choose random albums #795

Open duailibe opened 10 years ago

duailibe commented 10 years ago

So, sometimes I don't feel like choosing what I want to listen and just want something random. Since we already have the great random plugin, I don't think duplicating features is the best way to go here.

I'm looking for some suggestions :-)

sampsyo commented 10 years ago

One strategy—not sure whether it would work—would be to have the random plugin provide a query instead of a command. You would be able to say something like:

beet ls something random:5

and beets would pick 5 of the songs matching something. Then randomness could be used with anything based on queries, including the play plugin.

duailibe commented 10 years ago

That's a great idea. I'll start hacking on it and see what I can do with it.

duailibe commented 10 years ago

So it seems there's currently no easy way to provide a query based on a "field", like random:5 in the example you give, but instead only using a prefix. Besides that, there'd be no easy way for this query to track the current state (e.g., how many tracks it matched already).

Does this sound correct or am I missing something?

sampsyo commented 10 years ago

Yes, you've got this right on both counts.

Here are two ideas:

Overall, we should think of what the best UI would be for this feature (is random:5 the right interface? I don't currently have a better idea…) and hack until it's possible. :smiley:

duailibe commented 10 years ago

Thanks for the suggestions. I'm not that sure if we should hack these things, though. I do like the random:5 interface (I also can't think of a better one) but this is indeed abusing the field querying system. Do you think we'd have real use cases for "pseudo-fields" ? If so, I agree it would be a nice addition, but I'm not comfortable hacking that much just for this feature :-)

A simpler solution would be to simply implement the random feature in the play plugin and we'd be done with it. I prefer the idea of interoperability between plugins, but I the simplest solution here seems to be best. I'm curious about your opinion.

sampsyo commented 10 years ago

Yeah, it could be that this should be a longer-term thing. Feel free to add the random selection to play itself; we can go back later and figure out the general solution if we come up with something good.

On that note, it should actually now be relatively easy to add pseudo-fields. In #647, I'm adding a way for plugins, etc., to define types for flexible and computed fields. It should be possible to use this to specify a query type for a field that doesn't actually exist—just provide a Query subclass that doesn't inherit from FieldQuery and you should be good to go (I think).

jubalh commented 8 years ago

I am using:

beet random -n5 -p | xargs -d '\n' mpv

for similar purposes :-)

clach04 commented 2 years ago

I'm using:

beet play $(beet random -n 1 -f '$title $artist')

This can/will generate more than one random track if there are dupes (or remixes).

Also:

beet play "$(beet random -n 1 -p)"  # only works with one track, ensure handle spaces in path correctly