fix no id3 tag error

This commit is contained in:
Tomáš Mládek 2019-05-01 14:15:58 +02:00
parent 78f681791f
commit f93bc1a0eb

View file

@ -121,7 +121,13 @@ class DelojzaBot:
artist, title = self.extract_tags(info)
message.reply_text("Tagging as \"{}\" by \"{}\"".format(title, artist))
self.logger.info("Tagging %s w/ $s - $s...".format(globbed, title, artist))
id3 = mutagen.id3.ID3(globbed)
try:
id3 = mutagen.id3.ID3(globbed)
except mutagen.id3.ID3NoHeaderError:
mutafile = mutagen.File(globbed)
mutafile.add_tags()
mutafile.save()
id3 = mutagen.id3.ID3(globbed)
id3.add(mutagen.id3.TIT2(encoding=3, text=title))
if artist:
id3.add(mutagen.id3.TOPE(encoding=3, text=artist))