def _loadDetails(self): log("AudioBookHandler: Loading audio book %s (%s)" % (self.filePath, self.fileName)) # Check to see if we already have an image available self.coverImage = self._getExistingCoverImage() # Check in the database to see if this audio book is already recorded audiobookDB = AudioBooksDB() audiobookDetails = audiobookDB.getAudioBookDetails(self.filePath) if audiobookDetails not in [None, ""]: self.title = audiobookDetails['title'] self.numChapters = audiobookDetails['numChapters'] self.position = audiobookDetails['position'] self.chapterPosition = audiobookDetails['chapterPosition'] self.isComplete = audiobookDetails['complete'] else: self.position = 0 self.chapterPosition = 0 self.isComplete = False self._loadSpecificDetails() if self.title in [None, ""]: log("AudioBookHandler: No title found for %s, using filename" % self.filePath) self.title = self._getFallbackTitle() self.numChapters = len(self.chapters) # Now update the database entry for this audio book audiobookDB.addAudioBook(self.filePath, self.title, self.numChapters) del audiobookDB
def _loadDetails(self): log("AudioBookHandler: Loading audio book %s (%s)" % (self.filePath, self.fileName)) # Check in the database to see if this audio book is already recorded audiobookDB = AudioBooksDB() audiobookDetails = audiobookDB.getAudioBookDetails(self.filePath) if audiobookDetails not in [None, ""]: self.title = audiobookDetails['title'] self.numChapters = audiobookDetails['numChapters'] self.position = audiobookDetails['position'] self.chapterPosition = audiobookDetails['chapterPosition'] self.isComplete = audiobookDetails['complete'] self.hasArtwork = audiobookDetails['hasArtwork'] else: self.position = 0 self.chapterPosition = 0 self.isComplete = False self._loadBookDetails() if self.title in [None, ""]: log("AudioBookHandler: No title found for %s, trying ffmpeg load" % self.filePath) self._loadDetailsFromFfmpeg() if self.title in [None, ""]: log("AudioBookHandler: No title found for %s, using filename" % self.filePath) self.title = self._getFallbackTitle() self.numChapters = len(self.chapters) # Now update the database entry for this audio book audiobookDB.addAudioBook(self.filePath, self.title, self.numChapters) del audiobookDB
def _loadDetails(self): log("AudioBookHandler: Loading audio book %s (%s)" % (self.filePath, self.fileName)) # Check in the database to see if this audio book is already recorded audiobookDB = AudioBooksDB() audiobookDetails = audiobookDB.getAudioBookDetails(self.filePath) if audiobookDetails not in [None, ""]: # Convert to unicode when reading from DB. This fixes problems when # comparing to new items returned by mutagen which are unicode. try: self.title = audiobookDetails['title'].decode('utf-8') except: self.title = audiobookDetails['title'] self.numChapters = audiobookDetails['numChapters'] self.position = audiobookDetails['position'] self.chapterPosition = audiobookDetails['chapterPosition'] self.isComplete = audiobookDetails['complete'] self.hasArtwork = audiobookDetails['hasArtwork'] else: self.position = 0 self.chapterPosition = 0 self.isComplete = False self._loadBookDetails() if self.title in [None, ""]: log("AudioBookHandler: No title found for %s, trying ffmpeg load" % self.filePath) self._loadDetailsFromFfmpeg() if self.title in [None, ""]: log("AudioBookHandler: No title found for %s, using filename" % self.filePath) self.title = self._getFallbackTitle() self.numChapters = len(self.chapters) # Now update the database entry for this audio book audiobookDB.addAudioBook(self.filePath, self.title, self.numChapters) del audiobookDB