コード例 #1
0
class ArtistCoverManager(CoverManager):
    
    force_lastfm_check = True
    
    def __init__(self, plugin, artist_manager):
        self.cover_db = CoverArtExtDB(name='artist-art')
        
        super(ArtistCoverManager, self).__init__(plugin, artist_manager)

        self.cover_size = 72

        # create unknown cover and shadow for covers
        self.create_unknown_cover(plugin)
            
    def create_unknown_cover(self, plugin):
        # create the unknown cover
        self.unknown_cover = self.create_cover(
            rb.find_plugin_file(plugin, 'img/microphone.png'))

        super(ArtistCoverManager,self).create_unknown_cover(plugin)
        
    def update_pixbuf_cover(self, coverobject, pixbuf):
        # if it's a pixbuf, assign it to all the artist for the artist
        key = RB.ExtDBKey.create_storage('artist', coverobject.name)
        
        self.cover_db.store(key, RB.ExtDBSourceType.USER_EXPLICIT,
            pixbuf)
コード例 #2
0
class ArtistCoverManager(CoverManager):
    force_lastfm_check = True

    def __init__(self, plugin, artist_manager):
        self.cover_db = CoverArtExtDB(name='artist-art')

        super(ArtistCoverManager, self).__init__(plugin, artist_manager)

        self.cover_size = 72

        # create unknown cover and shadow for covers
        self.create_unknown_cover(plugin)

    def create_unknown_cover(self, plugin):
        # create the unknown cover
        self.unknown_cover = self.create_cover(
            rb.find_plugin_file(plugin, 'img/microphone.png'))

        super(ArtistCoverManager, self).create_unknown_cover(plugin)

    def update_pixbuf_cover(self, coverobject, pixbuf):
        # if it's a pixbuf, assign it to all the artist for the artist
        key = RB.ExtDBKey.create_storage('artist', coverobject.name)

        self.cover_db.store(key, RB.ExtDBSourceType.USER_EXPLICIT,
                            pixbuf)
コード例 #3
0
    def __init__(self, plugin, artist_manager):
        self.cover_db = CoverArtExtDB(name='artist-art')
        
        super(ArtistCoverManager, self).__init__(plugin, artist_manager)

        self.cover_size = 72

        # create unknown cover and shadow for covers
        self.create_unknown_cover(plugin)
コード例 #4
0
    def __init__(self, plugin, artist_manager):
        self.cover_db = CoverArtExtDB(name='artist-art')

        super(ArtistCoverManager, self).__init__(plugin, artist_manager)

        self.cover_size = 72

        # create unknown cover and shadow for covers
        self.create_unknown_cover(plugin)
コード例 #5
0
    def do_activate(self):
        '''
        Called by Rhythmbox when the plugin is activated. It creates the
        plugin's source and connects signals to manage the plugin's
        preferences.
        '''

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        
        #define .plugin text strings used for translation
        plugin = _('CoverArt Browser Search Providers')
        desc = _('Additional coverart search providers for Rhythmbox')

        print("CoverArtBrowser DEBUG - do_activate")
        self.shell = self.object
        self.db = self.shell.props.db

        self.art_store = RB.ExtDB(name="album-art")
        self.req_id = self.art_store.connect("request", self.album_art_requested)
        
        self.artist_store = CoverArtExtDB(name="artist-art")
        self.artist_req_id = self.artist_store.connect("request", self.artist_art_requested)
        

        peas = Peas.Engine.get_default()
        loaded_plugins = peas.get_loaded_plugins()

        self.peas_id = peas.connect_after('load-plugin', self.deactivate_plugin)

        if 'artsearch' in loaded_plugins:
            artsearch_info = peas.get_plugin_info('artsearch')
            self._unload_artsearch( peas, artsearch_info )

        self.peas = peas
        
        print("CoverArtBrowser DEBUG - end do_activate")
class CoverArtAlbumSearchPlugin(GObject.Object, Peas.Activatable):
    """
    Main class of the plugin. Manages the activation and deactivation of the
    plugin.
    """
    __gtype_name = 'CoverArtAlbumSearchPlugin'
    object = GObject.property(type=GObject.Object)

    def __init__(self):
        """
        Initialises the plugin object.
        """
        GObject.Object.__init__(self)
        if not rb3compat.compare_pygobject_version('3.9'):
            GObject.threads_init()

    def do_activate(self):
        """
        Called by Rhythmbox when the plugin is activated. It creates the
        plugin's source and connects signals to manage the plugin's
        preferences.
        """

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        # define .plugin text strings used for translation
        plugin = _('CoverArt Browser Search Providers')
        desc = _('Additional coverart search providers for Rhythmbox')

        print("CoverArtBrowser DEBUG - do_activate")
        self.shell = self.object
        self.db = self.shell.props.db

        self.art_store = RB.ExtDB(name="album-art")
        self.req_id = self.art_store.connect("request", self.album_art_requested)

        self.artist_store = CoverArtExtDB(name="artist-art")
        self.artist_req_id = self.artist_store.connect("request", self.artist_art_requested)

        self.peas = Peas.Engine.get_default()
        loaded_plugins = self.peas.get_loaded_plugins()

        self.peas_id = self.peas.connect_after('load-plugin', self.deactivate_plugin)

        if 'artsearch' in loaded_plugins:
            artsearch_info = self.peas.get_plugin_info('artsearch')
            self._unload_artsearch(self.peas, artsearch_info)

        self.csi_id = self.shell.connect("create_song_info", self.create_song_info)

        print("CoverArtBrowser DEBUG - end do_activate")

    def deactivate_plugin(self, engine, info):
        if info.get_module_name() == 'artsearch':
            self._unload_artsearch(engine, info)

    def _unload_artsearch(self, engine, info):
        engine.unload_plugin(info)
        dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.WARNING,
                                   Gtk.ButtonsType.OK,
                                   _("Conflicting plugin found."))
        dialog.format_secondary_text(
            _("The ArtSearch plugin has been deactivated"))
        dialog.run()
        dialog.destroy()

    def do_deactivate(self):
        """
        Called by Rhythmbox when the plugin is deactivated. It makes sure to
        free all the resources used by the plugin.
        """
        print("CoverArtBrowser DEBUG - do_deactivate")

        self.shell.disconnect(self.csi_id)
        self.csi_id = 0
        del self.shell
        del self.db
        self.art_store.disconnect(self.req_id)
        self.artist_store.disconnect(self.artist_req_id)
        self.peas.disconnect(self.peas_id)
        self.req_id = 0
        self.peas_id = 0
        self.art_store = None
        self.artist_store = None
        self.peas = None

        print("CoverArtBrowser DEBUG - end do_deactivate")

    def create_song_info(self, shell, song_info, is_multiple):
        if is_multiple is False:
            # following only valid for rhythmbox 3.2
            try:
                import sys

                artsearch_dir = self.peas.get_plugin_info('artsearch').get_module_dir()
                sys.path.append(artsearch_dir)
                from songinfo import AlbumArtPage

                x = AlbumArtPage(shell, song_info)
            except:
                pass

    def album_art_requested(self, store, key, last_time):
        searches = []

        current_list = get_search_providers()

        for provider in current_list:
            if provider == SearchPreferences.EMBEDDED_SEARCH:
                searches.append(EmbeddedSearch())
                searches.append(CoverAlbumSearch())
            if provider == SearchPreferences.LOCAL_SEARCH:
                searches.append(LocalSearch())
            if provider == SearchPreferences.CACHE_SEARCH:
                searches.append(OldCacheSearch())
            if provider == SearchPreferences.LASTFM_SEARCH:
                searches.append(LastFMSearch())
            if provider == SearchPreferences.MUSICBRAINZ_SEARCH:
                searches.append(MusicBrainzSearch())
            if provider == SearchPreferences.SPOTIFY_SEARCH:
                searches.append(SpotifySearch())
            # if provider == SearchPreferences.DISCOGS_SEARCH:
            #    searches.append(DiscogsSearch())
            if provider == SearchPreferences.COVERARTARCHIVE_SEARCH:
                searches.append(CoverartArchiveSearch())

        s = CoverSearch(store, key, last_time, searches)

        return s.next_search(True)

    def artist_art_requested(self, store, key, last_time):
        print("artist_art_requested")

        print(store)
        print(key)
        print(last_time)

        searches = []

        searches.append(LastFMArtistSearch())
        # searches.append(DiscogsSearch())

        s = ArtistCoverSearch(store, key, last_time, searches)

        print("finished artist_art_requested")
        return s.next_search(True)