Beispiel #1
0
 def shouldMoveToLibrary(self, artist, id3, mp3):
     try:
         fileFolderLibPath = self.albumFolder(artist, id3.year, id3.album)
         os.makedirs(fileFolderLibPath, exist_ok=True)
         fullFileLibPath = os.path.join(fileFolderLibPath,
                                        ProcessorBase.makeFileFriendly(
                                            ProcessorBase.trackName(id3.track, id3.title)))
         if not os.path.isfile(fullFileLibPath):
             # Does not exist copy it over
             return True
         else:
             # Does exist see if the one being copied is 'better' then the existing
             existingId3 = ID3(fullFileLibPath, self.processingOptions)
             if not existingId3.isValid():
                 return True
             existingId3Hash = hashlib.md5((str(artist.roadieId) + str(existingId3)).encode('utf-8')).hexdigest()
             id3Hash = hashlib.md5((str(artist.roadieId) + str(id3)).encode('utf-8')).hexdigest()
             if existingId3Hash == id3Hash:
                 # If the hashes are equal its Likely the same file
                 return False
             # If The existing is longer or has a higher bitrate then use existing
             if existingId3.length > id3.length and existingId3.bitrate > id3.bitrate:
                 return False
         return True
     except:
         self.logger.exception("shouldMoveToLibrary: Id3 [" + str(id3) + "]")
         return False