From f93bc1a0ebe6420a97990be79fb5c6e2a246bb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 1 May 2019 14:15:58 +0200 Subject: [PATCH] fix no id3 tag error --- delojza.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/delojza.py b/delojza.py index 4515e38..c482fc3 100755 --- a/delojza.py +++ b/delojza.py @@ -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))