TypeError: object of type ‘ID3TimeStamp’ has no len()

I have made this code, to get the year from an mp3, and if i print it, it works, but when i write to text box in my webpage, it gives an error(traceback below), but not always, sometimes the error not show, so i suspect it is from the way the mp3 is tagged:

nfo_year = ''
audio_filename = 'myfile.mp3'

f = mutagen.File(audio_filename)

audio = ID3(audio_filename)  # path: path to file

# Year
    nfo_year = audio['TDRC'].text[0]

logger_internet.info('Writing Year...')
AB_author = driver.find_element_by_name('year')

Traceback (most recent call last):
  File "D:ABredacted.py", line 1252, in <module>
  File "D:ABvenvlibsite-packagesseleniumwebdriverremotewebelement.py", line 478, in send_keys
    {'text': "".join(keys_to_typing(value)),
  File "D:ABvenvlibsite-packagesseleniumwebdrivercommonutils.py", line 150, in keys_to_typing
    for i in range(len(val)):
TypeError: object of type 'ID3TimeStamp' has no len()

my question is: an error on the mp3 tag or am i doing something wrong?


nfo_year is a timestamp object, of type ID3TimeStamp. You have to pass strings to AB_author.send_keys. Since print worked, you can try str(nfo_year).

Leave a Reply

Your email address will not be published. Required fields are marked *