from libs.config import get_config if __name__ == '__main__': config = get_config() db = SqliteDatabase() path = "mp3/" # fingerprint all files in a directory for filename in os.listdir(path): if filename.endswith(".mp3"): reader = FileReader(path + filename) audio = reader.parse_audio() song = db.get_song_by_filehash(audio['file_hash']) song_id = db.add_song(filename, audio['file_hash']) msg = ' * %s %s: %s' % ( colored('id=%s', 'white', attrs=['dark']), # id colored('channels=%d', 'white', attrs=['dark']), # channels colored('%s', 'white', attrs=['bold']) # filename ) print(msg % (song_id, len(audio['channels']), filename)) if song: hash_count = db.get_song_hashes_count(song_id) if hash_count > 0: msg = ' already exists (%d hashes), skip' % hash_count print(colored(msg, 'red'))
from libs.config import get_config if __name__ == "__main__": config = get_config() db = SqliteDatabase() path = "mp3/" # fingerprint all files in a directory for filename in os.listdir(path): if filename.endswith(".mp3"): reader = FileReader(path + filename) audio = reader.parse_audio() song = db.get_song_by_filehash(audio["file_hash"]) song_id = db.add_song(filename, audio["file_hash"]) msg = " * %s %s: %s" % ( colored("id=%s", "white", attrs=["dark"]), # id colored("channels=%d", "white", attrs=["dark"]), # channels colored("%s", "white", attrs=["bold"]), # filename ) print(msg % (song_id, len(audio["channels"]), filename)) if song: hash_count = db.get_song_hashes_count(song_id) if hash_count > 0: msg = " already exists (%d hashes), skip" % hash_count print(colored(msg, "red"))