Skip to content

Commit

Permalink
smartplaylist: Fix album_query (fix #1225)
Browse files Browse the repository at this point in the history
This is far less elegant and functional, but at least it is correct.
  • Loading branch information
sampsyo committed Jan 15, 2015
1 parent 38c5bb3 commit c1ce71f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions beetsplug/smartplaylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Generates smart playlists based on beets queries.
"""
from __future__ import print_function
from itertools import chain

from beets.plugins import BeetsPlugin
from beets import ui
Expand All @@ -30,11 +29,17 @@ def _items_for_query(lib, queries, album):
latter case, the results from each query are concatenated. `album`
indicates whether the queries are item-level or album-level.
"""
request = lib.albums if album else lib.items
if isinstance(queries, basestring):
return request(queries)
queries = [queries]
if album:
for query in queries:
for album in lib.albums(query):
for item in album.items():
yield item
else:
return chain.from_iterable(map(request, queries))
for query in queries:
for item in lib.items(query):
yield item


class SmartPlaylistPlugin(BeetsPlugin):
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Fixes:
:bug:`1212`
* Fix a crash when the importer deals with Unicode metadata in ``--pretend``
mode. :bug:`1214`
* :doc:`/plugins/smartplaylist`: Fix ``album_query`` so that individual files
are added to the playlist instead of directories. :bug:`1225`

For developers: The logging system in beets has been overhauled. Plugins now
each have their own logger, which helps by automatically adjusting the
Expand Down

0 comments on commit c1ce71f

Please sign in to comment.