1 (edited by ichneumon 2011-02-26 01:07:52)

Topic: New plugin - remove "Perfect" album matches

I though this one might be handy if anyone's tagging up a large quantity of music. Basically, it'll go through the list of albums in the right-hand treeview and remove any that have a perfect 1:1 matchup. That is, if there are duplicate files for a track, it stays. If there are any unsaved tag updates, it stays. If there are any tracks missing, it stays. Grab it from here if you need it. I've already caught a few mis-taggings this way.
The code very simple, and I based it on Aaron Lamber's "The Sorting Plugin".

Re: New plugin - remove "Perfect" album matches

Sounded neat,  but I only get a 404 when trying the link.

Re: New plugin - remove "Perfect" album matches

Now that was a bit odd. Somehow, the link gained a trailing forwardslash. Definitely wasn't me that did it, and it had (by my reckoning) 50-odd successful downloads beforehand. I've corrected the link above.

Re: New plugin - remove "Perfect" album matches

Downloaded, installed and it's all I hoped for.

This will make verifying changed tracks when refreshing tags that much simpler. Thanks!

Now all I need is something that will display/highlight the exact tags that have changed in the detail view, and I'll be all set. :-)

5 (edited by hrglgrmpf 2012-01-16 08:34:33)

Re: New plugin - remove "Perfect" album matches

Thanks a lot ichneumon! I find the plugin very useful! However, there were some errors with Picard 0.15:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/picard/ui/itemviews.py", line 752, in remove_album
    index = self.indexOfTopLevelItem(self.panel.item_from_object(album))
  File "/usr/lib/pymodules/python2.6/picard/ui/itemviews.py", line 193, in item_from_object
    return self._object_to_item[obj]

So I updated and simplified the plugin a bit. Now you have to mark all albums that you want to be checked for perfect matches (e.g. to select all, just type CTRL-A). Does this work for you? If yes, I would like to submit it to the plugins directory!

# -*- 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', '0.16']

# 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.get_num_unsaved_files() == 0 and album.loaded == True:
                self.tagger.remove_album(album)

register_album_action(RemovePerfectAlbums())

Re: New plugin - remove "Perfect" album matches

I tried the update and it seems to work, though it shows the remove perfect matches option twice on the plugins context menu, and I think only the second one works.

I think it would be nice to branch this plugin out so that it also has an option to remove empty albums, that is, ones in which there are no longer any songs being matched. I prefer not to delete them as I go since the GUI always scrolls back to the top of the list.

Re: New plugin - remove "Perfect" album matches

hrglgrmpf wrote:

Thanks a lot ichneumon! I find the plugin very useful! However, there were some errors with Picard 0.15:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/picard/ui/itemviews.py", line 752, in remove_album
    index = self.indexOfTopLevelItem(self.panel.item_from_object(album))
  File "/usr/lib/pymodules/python2.6/picard/ui/itemviews.py", line 193, in item_from_object
    return self._object_to_item[obj]

So I updated and simplified the plugin a bit. Now you have to mark all albums that you want to be checked for perfect matches (e.g. to select all, just type CTRL-A). Does this work for you? If yes, I would like to submit it to the plugins directory!

# -*- 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.get_num_unsaved_files() == 0 and album.loaded == True:
                self.tagger.remove_album(album)

register_album_action(RemovePerfectAlbums())

Hi is there any chance of getting this updated for 0.16 at all? I would find this a very useful plugin...

Re: New plugin - remove "Perfect" album matches

hrglgrmpf's version should already work on 0.16.

"Plugin API version" is a separate concept to the Picard version; and 0.15, 0.15.1 and 0.16 versions of Picard have the same API so plugins are (bugs-excepting) compatible with all those versions.

Re: New plugin - remove "Perfect" album matches

Yes, it works for 0.16, I also use it quite often. If this is working and is useful for others, and the author is ok with it (I will send him a message), I can send a pull request to upload it in the main plugin repository, so that it can be updated by the maintainers!

10 (edited by mightymouse2045 2012-01-16 07:12:14)

Re: New plugin - remove "Perfect" album matches

hmmm, I'm running musicbrainz 0.16 and when I installed the version updated by yourself (I changed the api version to 0.16), then I enable it, but when I go back into the plugins it's not enabled.

I will try changing the api version back to 0.15 and see if that makes any difference... lol I think that is probably why - but i'll let you know if I still have dramas

EDIT:

Nope it's still not working. I just install it via the plugins section under options, and then check it to enable it, but when i click ok and go back into options it's unchecked...

Re: New plugin - remove "Perfect" album matches

What does it say in Help > View Log during startup? One common cause of such problems is conflicting versions of a plugin in different plugin locations.

Re: New plugin - remove "Perfect" album matches

voiceinsideyou wrote:

What does it say in Help > View Log during startup? One common cause of such problems is conflicting versions of a plugin in different plugin locations.

Nothing in the log at startup. When I enable it, nothing gets added to the log either.

Basically as soon as I click ok in options after checking the box next to Perfect Albums it unchecks itself like I never enabled it in the first place...

Re: New plugin - remove "Perfect" album matches

I have no idea what's wrong in that case, sorry. That behaviour sounds weird.

Re: New plugin - remove "Perfect" album matches

voiceinsideyou wrote:

I have no idea what's wrong in that case, sorry. That behaviour sounds weird.

Can you give me a copy of your perfectalbums.py and I can try that instead?

Re: New plugin - remove "Perfect" album matches

mightymouse2045 wrote:
voiceinsideyou wrote:

I have no idea what's wrong in that case, sorry. That behaviour sounds weird.

Can you give me a copy of your perfectalbums.py and I can try that instead?

I've put the copy that runs on my system (with Picard 0.16) in the post above. What I remembered just now: With my version, you have to select (e.g. with CTRL-A) all releases that should be checked for removal! So:
* Select all releases in the left pane
* Right click -> Plugins -> Remove perfect albums

does it work now?

Re: New plugin - remove "Perfect" album matches

hrglgrmpf wrote:
mightymouse2045 wrote:
voiceinsideyou wrote:

I have no idea what's wrong in that case, sorry. That behaviour sounds weird.

Can you give me a copy of your perfectalbums.py and I can try that instead?

I've put the copy that runs on my system (with Picard 0.16) in the post above. What I remembered just now: With my version, you have to select (e.g. with CTRL-A) all releases that should be checked for removal! So:
* Select all releases in the left pane
* Right click -> Plugins -> Remove perfect albums

does it work now?

LOL - it was a space in the file name - doh! I just removed the space and reload musicbrainz and it's working now :D

Re: New plugin - remove "Perfect" album matches

Ahh interesting. Still, you shouldn't really get such strange behaviour with it becoming unticked and such. If you can give a set of steps to replicate it, perhaps you could create a ticket at http://tickets.musicbrainz.org/browse/PICARD ?

Re: New plugin - remove "Perfect" album matches

voiceinsideyou wrote:

Ahh interesting. Still, you shouldn't really get such strange behaviour with it becoming unticked and such. If you can give a set of steps to replicate it, perhaps you could create a ticket at http://tickets.musicbrainz.org/browse/PICARD ?

Done :)

Re: New plugin - remove "Perfect" album matches

hrglgrmpf wrote:

* Select all releases in the left pane
* Right click -> Plugins -> Remove perfect albums

I'm guessing you mean in the right pane instead of in the left one?

Re: New plugin - remove "Perfect" album matches

Ah, yes of course :-)!

Re: New plugin - remove "Perfect" album matches

I have the same bug as Quitch with two versions showing up in the plugins drop down when right clicking an album.

One of them takes on the capitalization within the py file, while the other does not. Only one actually works.

Would like to know how to get rid of the non functioning one.

Re: New plugin - remove "Perfect" album matches

For anyone else who may run into the bug, looking at help -> log lead me to the user appdata roaming picard folder which held an old version of the plugin, deletion of it from there fixed the problem.

Re: New plugin - remove "Perfect" album matches

Isn't that what I said to do at http://forums.musicbrainz.org/viewtopic … 179#p17179 ?

Re: New plugin - remove "Perfect" album matches

Pretty much, I thought your answer was for the other problems, rather than the two instances showing, with one doing nothing.

Re: New plugin - remove "Perfect" album matches

Great plugin! IMO should be a built-in option to the main prog. . .


Enhancement suggestion:

I have my files tree setup so I process both my FLAC and my MP3 files together.

Picard appropriately groups all the files of both types together into a single album.

However if say all the FLACs are "perfect" matches but some of the MP3s aren't, the plugin is treating the whole album as a single set, only removing on a per-album basis when **all** the tracks match perfectly (right? this is as intended I assume. . .)

I personally would be much happier if all the perfectly matched **tracks** were removed.

The only downside I can see is for those with a lot of singles, which I never have, I don't bother managing tracks that aren't part of full albums.

Obviously just my POV, take it for the 2¢ it's worth.