Make the Template object an attribute.

This commit is contained in:
David Logie 2015-01-19 13:44:14 +00:00
parent 3317580296
commit 2fae94a93a

View file

@ -62,17 +62,18 @@ class MBSyncPlugin(BeetsPlugin):
pretend = opts.pretend
write = opts.write
query = ui.decargs(args)
tmpl = Template(ui._pick_format(True, opts.format))
self.singletons(lib, query, move, pretend, write, tmpl)
self.albums(lib, query, move, pretend, write, tmpl)
self.template = Template(ui._pick_format(True, opts.format))
def singletons(self, lib, query, move, pretend, write, tmpl):
self.singletons(lib, query, move, pretend, write)
self.albums(lib, query, move, pretend, write)
def singletons(self, lib, query, move, pretend, write):
"""Retrieve and apply info from the autotagger for items matched by
query.
"""
for item in lib.items(query + ['singleton:true']):
item_formatted = item.evaluate_template(tmpl)
item_formatted = item.evaluate_template(self.template)
if not item.mb_trackid:
self._log.info(u'Skipping singleton with no mb_trackid: {0}',
item_formatted)
@ -91,13 +92,13 @@ class MBSyncPlugin(BeetsPlugin):
autotag.apply_item_metadata(item, track_info)
apply_item_changes(lib, item, move, pretend, write)
def albums(self, lib, query, move, pretend, write, tmpl):
def albums(self, lib, query, move, pretend, write):
"""Retrieve and apply info from the autotagger for albums matched by
query and their items.
"""
# Process matching albums.
for a in lib.albums(query):
album_formatted = a.evaluate_template(tmpl)
album_formatted = a.evaluate_template(self.template)
if not a.mb_albumid:
self._log.info(u'Skipping album with no mb_albumid: {0}',
album_formatted)