In Mutagen i read tags form an audiofile but when the tag don't exist, i get an error of course.
audio = ID3(musicfile)
print(audio['TXXX:SERIES'].text[0])
KeyError: 'TXXX:SERIES'
how to move on if tag don't exist?
i have tried:
if audio['TXXX:SERIES'].text[0] is None:
print('No series')
else:
also
if not audio['TXXX:SERIES'].text[0]:
print('No series')
else:
still gives an error.
Traceback (most recent call last):
File "D:\xxxxx\all_the_program.py", line 163, in <module>
if audio['TXXX:SERIES'].text[0] is None:
File "D:\xxxxx\venv\lib\site-packages\mutagen\_util.py", line 537, in __getitem__
return self.__dict[key]
Traceback (most recent call last):
File "D:\xxxxx\all_the_program.py", line 163, in <module>
if not audio['TXXX:SERIES'].text[0]:
File "D:\xxxxxx\venv\lib\site-packages\mutagen\_util.py", line 537, in __getitem__
return self.__dict[key]
KeyError: 'TXXX:SERIES'