Closed Domi250 closed 1 year ago
In metadata.py embed_metadata() there are multiple function calls on variables without checking whether they are None, e.g. line 132 len(song.genres) or line 182 zfill()). This can lead to errors/exceptions if they actually are None, for any reason. Fix: Add if var != None -checks
Fixed
For example, when using spotdl meta on songs not having all id3 tags values set which are used by spotdl (for me it was a song downloaded with version < 4.1.0). Spotdl first reads existing tags from the current song file in order to carry them over into the newly created song object. But Spotdl tries to extracts all values found in the TAG_PRESET list (in get_file_metadata()), and if they don't exist they are saved into the new song object as None. Summarized program flow: meta.py:process_file() -> in search.py:get_song_from_file_metadata(file) extract old tags with get_file_metadata() and call song.py:from_missing_data() to copy them. Fix: Check for missing tags (==None) and ~download the correct value from Spotify instead.
No clue how I didn't notice this change, it was tottaly wrong. I must have been sleepy at that time lol. Now it should be better, but can you double check 💀
Classic midnight-programming ^^ It works now
System OS
Linux
Python Version
3.7 (CPython)
Install Source
pip / PyPi
Install version / commit hash
4.1.3
Expected Behavior vs Actual Behavior
Hi, I would have fixed this myself, but I wasn't sure whether my take on this is the same as yours. I'll add a trace from a song without genres tag, but I doubt whether it's useful. In my opinion there are actually 2 (maybe 3?) bugs:
In metadata.py embed_metadata() there are multiple function calls on variables without checking whether they are None, e.g. line 132
len(song.genres)
or line 182zfill()
). This can lead to errors/exceptions if they actually areNone
, for any reason. Fix: Addif var != None
-checksFor example, when using
spotdl meta
on songs not having all id3 tags values set which are used by spotdl (for me it was a song downloaded with version < 4.1.0). Spotdl first reads existing tags from the current song file in order to carry them over into the newly createdsong
object. But Spotdl tries to extracts all values found in the TAG_PRESET list (inget_file_metadata()
), and if they don't exist they are saved into the new song object asNone
. Summarized program flow:meta.py:process_file()
-> insearch.py:get_song_from_file_metadata(file)
extract old tags withget_file_metadata()
and callsong.py:from_missing_data()
to copy them. Fix: Check for missing tags (==None
) and ~download the correct value from Spotify instead.Aside from these bugs, I was wondering why
meta
operates like this. It does not just update all tags for the given song.meta
looks whether the 5 fields artist, artists, name, lyrics, and album_art are set, and only if they aren't applies metadata. And even then, old metadata is preserved in the existing song file instead of updating it. The--force-update-metadata
option skips the check for these 5 fields, but still preserves existing metadata, which is even weirder, and to me seems like a 3rd bug.Steps to reproduce - Ensure to include actual links!
See above
Traceback
Other details
No response