Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # savecover - saves Exaile album covers to the location of the music file
- # Copyright (C) 2008 slaytanic <slaytanic@gmail.com>
- #
- # 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 of the License, 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.,
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- import gtk
- from gettext import gettext as _
- import xl.plugins as plugins
- from shutil import copyfile
- import os
- PLUGIN_NAME = _("Save Cover")
- PLUGIN_AUTHORS = ['slaytanic <slaytanic@gmail.com>']
- PLUGIN_VERSION = '0.1.1'
- PLUGIN_DESCRIPTION = _("Saves the album cover image to the location of the music file.")
- PLUGIN_ENABLED = False
- b = gtk.Button()
- PLUGIN_ICON = b.render_icon(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU)
- b.destroy()
- CONNS = plugins.SignalContainer()
- def initialize():
- """
- Called when the plugin is enabled
- """
- CONNS.connect(APP.player, 'play-track', _play_track)
- # CONNS.connect(APP.cover, 'image-changed', _image_changed)
- return True
- def destroy():
- """
- Called when the plugin is disabled
- """
- CONNS.disconnect_all()
- def _play_track(exaile, track):
- """
- Called when playback on a track starts ("play-track" event)
- """
- cover = exaile.exaile.cover_manager.fetch_cover(track, True)
- if "nocover" in cover:
- print _("[savecover] No cover available for the current track!")
- else:
- print _("[savecover] Cover for the current track: %s" % cover)
- track = track.loc
- print _("[savecover] Current track location: %s" % track)
- if "nocover" in cover:
- return False
- cover_dst = os.path.join(os.path.dirname(track), "folder.jpg")
- if not os.path.exists(cover_dst):
- copyfile(cover, cover_dst)
- print _("[savecover] Cover saved: %s" % cover_dst)
- return True
- else:
- print _("[savecover] Cover already present: %s" % cover_dst)
- return False
Add Comment
Please, Sign In to add comment