Query string for computed fields. Fixes #693

This commit is contained in:
Thomas Scholtes 2014-04-16 14:18:07 +02:00
parent 4e2828668c
commit b8687999e2
2 changed files with 2 additions and 8 deletions

View file

@ -20,7 +20,6 @@ from beets.plugins import BeetsPlugin
from beets import autotag, library, ui, util from beets import autotag, library, ui, util
from beets.autotag import hooks from beets.autotag import hooks
from beets import config from beets import config
from beets import dbcore
log = logging.getLogger('beets') log = logging.getLogger('beets')
@ -29,17 +28,12 @@ def mbsync_singletons(lib, query, move, pretend, write):
"""Retrieve and apply info from the autotagger for items matched by """Retrieve and apply info from the autotagger for items matched by
query. query.
""" """
singletons_query = library.get_query(query, library.Item) for item in lib.items(query + ['singletons:true']):
singletons_query.subqueries.append(
dbcore.query.BooleanQuery('singleton', True)
)
for item in lib.items(singletons_query):
if not item.mb_trackid: if not item.mb_trackid:
log.info(u'Skipping singleton {0}: has no mb_trackid' log.info(u'Skipping singleton {0}: has no mb_trackid'
.format(item.title)) .format(item.title))
continue continue
# Get the MusicBrainz recording info. # Get the MusicBrainz recording info.
track_info = hooks.track_for_mbid(item.mb_trackid) track_info = hooks.track_for_mbid(item.mb_trackid)
if not track_info: if not track_info:
@ -118,7 +112,6 @@ def apply_item_changes(lib, item, move, pretend, write):
item.store() item.store()
def mbsync_func(lib, opts, args): def mbsync_func(lib, opts, args):
"""Command handler for the mbsync function. """Command handler for the mbsync function.
""" """

View file

@ -21,6 +21,7 @@ from helper import TestHelper,\
from beets.library import Item from beets.library import Item
class MbsyncCliTest(unittest.TestCase, TestHelper): class MbsyncCliTest(unittest.TestCase, TestHelper):
def setUp(self): def setUp(self):