diff --git a/config.yaml b/config.yaml index 6b82489..536ebc1 100644 --- a/config.yaml +++ b/config.yaml @@ -87,7 +87,7 @@ smartplaylist: - name: "precision.m3u" query: ['plprecision:1'] - name: "exercise.m3u" - query: ['label:exercise-'] # ['^plexercise::^$ plexercise-'] + query: ['sorted_playlist:exercise'] # ['^plexercise::^$ plexercise-'] - name: "chiptune.m3u" query: ['genre:chiptune', 'genre:8-bit', 'plchiptune:1'] diff --git a/plugins/beetslabels.py b/plugins/beetslabels.py index f550796..342c53c 100644 --- a/plugins/beetslabels.py +++ b/plugins/beetslabels.py @@ -46,10 +46,23 @@ def parse_sorted_query_override( """Given a list of strings, create the `Query` and `Sort` that they represent. """ - # First, expand any playlist: macros + # First, expand any playlist: and sorted_playlist: macros expanded_parts = [] + for part in parts: - if part.startswith('playlist:') and not re.match(r"[+-]$", part): + if part.startswith('sorted_playlist:'): + # Extract playlist name + playlist_name = part[len("sorted_playlist:"):] + + if valid_playlist(playlist_name): + # Expand to the query + expanded_parts.extend(expand_playlist_query(playlist_name)) + # Inject the sort + expanded_parts.append(f"playlist:{playlist_name}-") + else: + # Unknown playlist, just let it go through + expanded_parts.append(part) + elif part.startswith('playlist:') and not re.match(r"[+-]$", part): playlist_name = part[len("playlist:"):] if valid_playlist(playlist_name):