=== added directory 'plugins/move_covers' === added file 'plugins/move_covers/PLUGININFO' --- plugins/move_covers/PLUGININFO 1970-01-01 00:00:00 +0000 +++ plugins/move_covers/PLUGININFO 2010-03-20 08:39:03 +0000 @@ -0,0 +1,4 @@ +Version='0.0.1' +Authors=['Johannes Schwarz '] +Name=_('Move covers') +Description=_('Plugin to move all downloaded covers to your music directory.') === added file 'plugins/move_covers/__init__.py' --- plugins/move_covers/__init__.py 1970-01-01 00:00:00 +0000 +++ plugins/move_covers/__init__.py 2010-03-20 09:21:40 +0000 @@ -0,0 +1,50 @@ +# Copyright (C) 2010 Johannes Schwarz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +import shutil +import os.path + +from xl.trax import search +from xl import event +from xl import settings +import mcprefs + + +def enable(exaile): + if exaile.loading: + event.add_callback(_enable, "exaile_loaded") + else: + _enable(None, exaile, None) + +def _enable(eventname, exaile, nothing): +# tracks = exaile.collection.get_tracks() + albums = [x.track for x in search.search_tracks_from_string( + exaile.collection, ('! %s==__null__' % 'album'))] + + cover_name = settings.get_option('plugin/move_covers/covername', 'cover') + for album in albums: + key = exaile.covers._get_track_key(album) + db_string = exaile.covers.db.get(key) + if db_string: + source, data = db_string.split(":", 1) + if source == 'cache': + des = os.path.join(os.path.dirname(album.local_file_name()), 'cover') + src = os.path.join(exaile.covers.location, 'cache', data) + shutil.copyfile(src,des) + + +def disable(exaile): + pass === added file 'plugins/move_covers/mcprefs.py' --- plugins/move_covers/mcprefs.py 1970-01-01 00:00:00 +0000 +++ plugins/move_covers/mcprefs.py 2010-03-20 09:05:43 +0000 @@ -0,0 +1,12 @@ +import os +from xlgui.prefs import widgets +from xl import xdg +from xl.nls import gettext as _ + +name = _('Move Covers') +basedir = os.path.dirname(os.path.realpath(__file__)) +ui = os.path.join(basedir, 'move_covers.ui') + +class CoverName(widgets.PrefsItem): + default = 'cover' + name = 'plugin/streamripper/relay_port' === added file 'plugins/move_covers/move_covers.ui' --- plugins/move_covers/move_covers.ui 1970-01-01 00:00:00 +0000 +++ plugins/move_covers/move_covers.ui 2010-03-20 09:06:10 +0000 @@ -0,0 +1,43 @@ + + + + + + + + True + vertical + + + True + 2 + + + True + 0 + 5 + Cover name: + + + + + True + True + + + + 1 + 2 + + + + + False + False + 0 + + + + + +