From bf904187e2b829eb69a3929cd8d04498f0bb9aa2 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 21 Apr 2013 20:55:07 -0700 Subject: [PATCH] smartplaylist: split query w/ shlex (fixes #256) --- beetsplug/smartplaylist.py | 4 ++-- docs/changelog.rst | 9 ++++++--- docs/plugins/smartplaylist.rst | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index b77ea0d5e..164029a41 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -17,7 +17,7 @@ from __future__ import print_function from beets.plugins import BeetsPlugin -from beets import config, ui +from beets import config, ui, library from beets.util import normpath, syspath from beets.util.functemplate import Template import os @@ -36,7 +36,7 @@ def update_playlists(lib): relative_to = normpath(relative_to) for playlist in playlists: - items = lib.items(playlist['query']) + items = lib.items(library.AndQuery.from_string(playlist['query'])) m3us = {} basename = playlist['name'].encode('utf8') # As we allow tags in the m3u names, we'll need to iterate through diff --git a/docs/changelog.rst b/docs/changelog.rst index 661c0d811..fb4e31608 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,15 +23,18 @@ Changelog * When listing the items in an album, the items are now always in track-number order. This should lead to more predictable listings from the :doc:`/plugins/importfeeds`. +* :doc:`/plugins/smartplaylist`: Queries are now split using shell-like syntax + instead of just whitespace, so you can now construct terms that contain + spaces. +* :doc:`/plugins/lastgenre`: The ``force`` config option now defaults to true + and controls the behavior of the import hook. (Previously, new genres were + always forced during import.) * :doc:`/plugins/web`: Fix an error when specifying the hostname on the command line. * :doc:`/plugins/web`: The underlying API was expanded slightly to support `Tomahawk`_ collections. And file transfers now have a "Content-Length" header. Thanks to Uwe L. Korn. * :doc:`/plugins/lastgenre`: Fix an error when using genre canonicalization. -* :doc:`/plugins/lastgenre`: The ``force`` config option now defaults to true - and controls the behavior of the import hook. (Previously, new genres were - always forced during import.) .. _Tomahawk: http://www.tomahawk-player.org/ diff --git a/docs/plugins/smartplaylist.rst b/docs/plugins/smartplaylist.rst index 790df1f99..206815c68 100644 --- a/docs/plugins/smartplaylist.rst +++ b/docs/plugins/smartplaylist.rst @@ -30,8 +30,10 @@ If you intend to use this plugin to generate playlists for MPD, you should set You can generate as many playlists as you want by adding them to the ``playlists`` section, using beets query syntax (see :doc:`/reference/query`) for ``query`` and the file name to be generated for -``name``. If you have existing files with the same names, you should -back them up---they will be overwritten when the plugin runs. +``name``. The query will be split using shell-like syntax, so if you need to +use spaces in the query, be sure to quote them (e.g., ``artist:"The Beatles"``). +If you have existing files with the same names, you should back them up---they +will be overwritten when the plugin runs. For more advanced usage, you can use template syntax (see :doc:`/reference/pathformat/`) in the ``name`` field. For example::