Topic: For plugin, how to iterate through an album's tracks and save files?
I'm working with the "Remove Perfect" plugin, trying to add in a bulk 'Save' call before the album is removed. I can't get this to work, however. Can anyone spot what I'm doing wrong?
# -*- coding: utf-8 -*-
PLUGIN_NAME = u'Remove Perfect Albums'
PLUGIN_AUTHOR = u'ichneumon, hrglgrmpf'
PLUGIN_DESCRIPTION = u'''Remove all perfectly matched albums from the selection.'''
PLUGIN_VERSION = '0.2'
PLUGIN_API_VERSIONS = ['0.15']
# heavily based on code from 'The Sorting Plugin' by Aaron Lambers
# see http://forums.musicbrainz.org/viewtopic.php?id=2489
# Updated to Picard 0.15 and simplified by hrglgrmpf
from picard.album import Album
from picard.ui.itemviews import BaseAction, register_album_action
class RemovePerfectAlbums(BaseAction):
NAME = 'Remove perfect albums'
def callback(self, objs):
for album in objs:
if isinstance(album, Album) and album.is_complete() and album.get_num_unmatched_files() == 0\
and album.get_num_matched_tracks() == len(list(album.iterfiles()))
and album.loaded == True:
for track in album.tracks:
for file in track.linked_files:
self.tagger.save(file)
self.tagger.remove_album(album)
register_album_action(RemovePerfectAlbums())