Exemplo n.º 1
0
    def getCoverImage(self, tryUtf8=False):
        if self.coverImage is None:
            # Check to see if we already have an image available
            self.coverImage = self._getExistingCoverImage()

        # Before we go checking the actual file, see if we recorded that
        # we have already checked and there was not any
        if self.hasArtwork != 0:
            # If nothing was cached, then see if it can be extracted from the metadata
            if self.coverImage is None:
                self.coverImage = self._saveAlbumArtFromMetadata(self.filePath)

            # Last resort is to try and extract with ffmpeg
            # Only do the ffmpeg check if using the ffmpeg executable as
            # that is the only one that will get the album artwork
            if (self.coverImage is None) and (Settings.getFFmpegSetting() == Settings.FFMPEG_EXEC):
                self._loadDetailsFromFfmpeg()

            # Check if we have now found artwork that we want to store
            audiobookDB = AudioBooksDB()
            self.hasArtwork = 0
            if self.coverImage not in [None, ""]:
                self.hasArtwork = 1
            # Update the database with the artwork status
            audiobookDB.setHasArtwork(self.filePath, self.hasArtwork)
            del audiobookDB

        coverImageValue = self.coverImage
        # Make sure the cover is correctly encoded
        if tryUtf8 and (coverImageValue not in [None, ""]):
            try:
                coverImageValue = coverImageValue.encode("utf-8")
            except:
                pass

        return coverImageValue
Exemplo n.º 2
0
    def getCoverImage(self, tryUtf8=False):
        if self.coverImage is None:
            # Check to see if we already have an image available
            self.coverImage = self._getExistingCoverImage()

        # Before we go checking the actual file, see if we recorded that
        # we have already checked and there was not any
        if self.hasArtwork != 0:
            # If nothing was cached, then see if it can be extracted from the metadata
            if self.coverImage is None:
                self.coverImage = self._saveAlbumArtFromMetadata(self.filePath)

            # Last resort is to try and extract with ffmpeg
            # Only do the ffmpeg check if using the ffmpeg executable as
            # that is the only one that will get the album artwork
            if (self.coverImage is None) and (Settings.getFFmpegSetting() == Settings.FFMPEG_EXEC):
                self._loadDetailsFromFfmpeg()

            # Check if we have now found artwork that we want to store
            audiobookDB = AudioBooksDB()
            self.hasArtwork = 0
            if self.coverImage not in [None, ""]:
                self.hasArtwork = 1
            # Update the database with the artwork status
            audiobookDB.setHasArtwork(self.filePath, self.hasArtwork)
            del audiobookDB

        coverImageValue = self.coverImage
        # Make sure the cover is correctly encoded
        if tryUtf8 and (coverImageValue not in [None, ""]):
            try:
                coverImageValue = coverImageValue.encode("utf-8")
            except:
                pass

        return coverImageValue