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

smartplaylist: Respect sort terms in queries #1137

Closed
djl opened this issue Dec 11, 2014 · 5 comments · Fixed by #1138
Closed

smartplaylist: Respect sort terms in queries #1137

djl opened this issue Dec 11, 2014 · 5 comments · Fixed by #1138
Labels
bug bugs that are confirmed and actionable

Comments

@djl
Copy link
Member

djl commented Dec 11, 2014

It would be nice to be able sort items in smart playlists, like so:

smartplaylist:
  relative_to: ~/music
  playlist_dir: ~/.mpd/playlists
  playlists:
    - name: '2014.m3u'
      query: 'year:2014 added+'
    - name: 'imported-%time{$added,%Y-%m}.m3u'
      query: "added:: path+"

I'm unfamiliar with the code but it looks like the smartplaylist plugin discards the query sort field when building playlists. Would it be possible to keep the custom sort?

@sampsyo sampsyo added the bug bugs that are confirmed and actionable label Dec 11, 2014
@sampsyo
Copy link
Member

sampsyo commented Dec 11, 2014

Indeed; it is unfortunate that the plugin discards the sort—I 100% agree that this deserves fixing.

@sampsyo sampsyo changed the title Sorting items in smart playlists smartplaylist: Respect sort terms in queries Dec 11, 2014
@PierreRust
Copy link
Collaborator

For a single query it should be relatively easy to preserve the sort , I think we simply need to add it to the call lib.albums(query): and lib.items(query); a few lines bellow.

But when using a list of query, which is supported by the plugin, which sort specification should we use ?
For example :

name: 'BeatlesUniverse.m3u'
query: ['artist:beatles added+', 'genre:"beatles cover year+"']

@djl
Copy link
Member Author

djl commented Dec 12, 2014

Intuitively, I would assume that would produce a list made from joining the results of two sorted queries (query1.extend(query2)).

@djl
Copy link
Member Author

djl commented Dec 12, 2014

Here's my attempt at a solution plus the config I tested with:

smartplaylist:
  playlists:
    - name: 'year-2014.m3u'
      query: ['year:2014 path-', 'year:2012 added+']
    - name: 'imported-%time{$added,%Y-%m}.m3u'
      query: "added:: path+"

The resulting playlists contain the items I expected when compared with a handful of manually built playlists.

As I said I'm not familiar with the code base so this could be the wrong way to do it but it seems to work :)

@sampsyo
Copy link
Member

sampsyo commented Dec 12, 2014

This looks great, @djl! Could you please open a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants