You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi,
when I try to use fingerprint_file I get the following error:
" _fingerprint_worker() got an unexpected keyword argument 'song_name' "
I just pass one argument to the function.
" djv.fingerprint_file(file_path)"
From the library source code:
song_name_from_path=decoder.get_audio_name_from_path(file_path)
song_hash=decoder.unique_hash(file_path)
song_name=song_nameorsong_name_from_path```
Hereyoucanseethatfile_pathisnecessary, butsong_nameisoptional. SoI'mactuallydoingeverythingright, Igues...
I've even made sure that the filenames passed in are certainly strings, thought that unexpected things happen... but that don'tsolvesmyissue.
Here'sjustmyscript, maybeyoucandosomethingwithit...
```pythonimportosimportargparseimportdatetimefromdejavuimportDejavu# load config from a JSON file (or anything outputting a python dictionary)config= {
"database": {
"host": "db",
"user": "postgres",
"password": "password",
"database": "dejavu"
},
"database_type": "postgres"
}
defread_fingerprinted_files(directory):
file_list= []
try:
withopen(os.path.join(directory, 'fingerprinted.txt'), 'r') asf:
lines=f.readlines()
file_list= [line.strip() forlineinlines[2:]] # Skip the first two lines (date and 'Files:')exceptFileNotFoundError:
passreturnfile_listdefwrite_fingerprinted_file(directory, files, supported_extensions):
withopen(os.path.join(directory, 'fingerprinted.txt'), 'w') asf:
f.write(f"Fingerprinted on: {datetime.datetime.now()}\n")
f.write("Files:\n")
forfileinfiles:
ifos.path.splitext(file)[1].lower() insupported_extensions:
f.write(f"{file}\n")
deffingerprint_file(djv, file_path):
try:
ifnotisinstance(file_path, str):
file_path=str(file_path)
djv.fingerprint_file(file_path)
print(f"Fingerprinted: {file_path}")
exceptExceptionase:
print(f"Error fingerprinting {file_path}: \n{e}")
if__name__=='__main__':
parser=argparse.ArgumentParser(description="Fingerprint audio files in a directory and its subdirectories.")
parser.add_argument("directory", help="The path to the directory containing audio files.")
args=parser.parse_args()
# Supported audio file extensions: mp3, m4a, wav, etc.supported_extensions= [".mp3", ".m4a", ".wav"]
# create a Dejavu instancedjv=Dejavu(config)
# Navigate through the main directory and each subdirectoryforroot, dirs, filesinos.walk(args.directory):
ifroot!=args.directory: # To avoid fingerprinting the parent directory itselfexisting_files=read_fingerprinted_files(root)
current_files= [fileforfileinfilesifos.path.splitext(file)[1].lower() insupported_extensions]
ifset(existing_files) ==set(current_files):
print(f"Skipping directory (no changes): {root}")
continue# Fingerprint each file individuallyprint(f"Fingerprinting directory: {root}")
forfileincurrent_files:
full_path=os.path.join(root, file)
fingerprint_file(djv, full_path)
write_fingerprinted_file(root, current_files, supported_extensions)```
The text was updated successfully, but these errors were encountered:
hi,
when I try to use fingerprint_file I get the following error:
" _fingerprint_worker() got an unexpected keyword argument 'song_name' "
I just pass one argument to the function.
" djv.fingerprint_file(file_path)"
From the library source code:
The text was updated successfully, but these errors were encountered: