Esempio n. 1
0
    def __searchAlbumArt(self, artist, album, filename):
        """Execute album art search thread"""

        # base64 encode artist and album so there can be a '/' in the artist or
        # album
        artist_album = artist + " - " + album
        artist_album = artist_album.encode("base64")

        album_art_file = os.path.join(
            self.config.ALBUM_ART_DIR, artist_album + ".jpg")
        if not os.path.exists(album_art_file):
            # Search for local albumart
            if os.path.exists(filename[:filename.rfind('/')+1]+"cover.jpg"):
                shutil.copyfile(filename[:filename.rfind('/')+1]+"cover.jpg",
                    album_art_file)
            elif os.path.exists(filename[:filename.rfind('/')+1]+"folder.jpg"):
                shutil.copyfile(filename[:filename.rfind('/')+1]+"folder.jpg",
                    album_art_file)
            # Local not found -> try internet
            else:
                if self.config.download_album_art:
                    if album != "Unknown album" and artist != "Unknown Artist":
                        loader_thread = AlbumArtDownloader(album, artist,
                            self.config.ALBUM_ART_DIR)
                        loader_thread.start()
Esempio n. 2
0
    def __searchAlbumArt(self, artist, album, filename):
        """Execute album art search thread"""

        # base64 encode artist and album so there can be a '/' in the artist or
        # album
        artist_album = artist + " - " + album
        artist_album = artist_album.encode("base64")

        album_art_file = os.path.join(self.config.ALBUM_ART_DIR,
                                      artist_album + ".jpg")
        if not os.path.exists(album_art_file):
            # Search for local albumart
            if os.path.exists(filename[:filename.rfind('/') + 1] +
                              "cover.jpg"):
                shutil.copyfile(
                    filename[:filename.rfind('/') + 1] + "cover.jpg",
                    album_art_file)
            elif os.path.exists(filename[:filename.rfind('/') + 1] +
                                "folder.jpg"):
                shutil.copyfile(
                    filename[:filename.rfind('/') + 1] + "folder.jpg",
                    album_art_file)
            # Local not found -> try internet
            else:
                if self.config.download_album_art:
                    if album != "Unknown album" and artist != "Unknown Artist":
                        loader_thread = AlbumArtDownloader(
                            album, artist, self.config.ALBUM_ART_DIR)
                        loader_thread.start()
Esempio n. 3
0
    def _get_disc_information(self):
        """
        Fetch album information from the Internet and create widgets based
        on received data.
        """
        try:
            disc = self.music_library.get_compact_disc_information()

            title = disc.title
            artist = disc.artist
            tracks = disc.tracks

            self.playlist = Playlist(tracks)
            self._create_album_info(title, artist, tracks, disc.length)
            self.track_menu = self._create_track_menu(tracks)
            self.add(self.track_menu)
            self._create_album_cover_texture(artist, title)

            self.li = ListIndicator(0.75, 0.8, 0.2, 0.045,
                ListIndicator.VERTICAL)
            self.li.set_maximum(len(tracks))
            self.add(self.li)

            art_file = os.path.join(self.config.ALBUM_ART_DIR,
                artist + " - " + title + ".jpg")
            if artist != "Unknown artist" and not os.path.exists(art_file):
                art_search = AlbumArtDownloader(title, artist,
                    self.config.ALBUM_ART_DIR, self._update_albumart)
                art_search.start()

        except cdrom.error:
            # No disc in drive
            self.has_disc = False
            no_disc = Label(0.05, "title", 0.5, 0.5,
                _("No audio disc in drive"))
            no_disc.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
            self.add(no_disc)

        # Remove loading animation
        self.throbber.hide()
        self.remove(self.throbber)
        del self.throbber

        # This function should be called only once (gobject timeout)
        return False