Ejemplo n.º 1
0
 def GetKeyFromFile(file):
     musf = AudioFile()
     musf.Open(file)
     buf = musf.ReadAudioStream(100*1024)	# 100KB from audio data
     musf.Close()
     # calculate hashkey
     m = hashlib.md5(); m.update(buf);
     return m.hexdigest()
 def GetKeyFromFile(file):
     musf = AudioFile()
     musf.Open(file)
     buf = musf.ReadAudioStream(100*1024)	# 100KB from audio data
     musf.Close()
     # buffer will be empty for streaming audio
     if not buf:
         return
     # calculate hashkey
     m = hashlib.md5(); m.update(buf);
     return m.hexdigest()
Ejemplo n.º 3
0
 def GetKeyFromFile(file):
     musf = AudioFile()
     musf.Open(file)
     ext = file[file.rfind('.'):].lower()
     if ext == '.ogg':
         buf = musf.ReadAudioStream(160 * 1024,
                                    11)  # 160KB excluding header
     elif ext == '.wma':
         buf = musf.ReadAudioStream(160 * 1024,
                                    24)  # 160KB excluding header
     else:
         buf = musf.ReadAudioStream(160 * 1024)  # 160KB from audio data
     musf.Close()
     # calculate hashkey
     m = hashlib.md5()
     m.update(buf)
     return m.hexdigest()