From 0e3c2c9b1b4fbfdf38dd675e2ce112925f5f278d Mon Sep 17 00:00:00 2001
From: Antoine Tenart <antoine.tenart@ack.tf>
Date: Fri, 22 Mar 2019 16:33:59 +0100
Subject: [PATCH] libmat2: audio: not all id3 types have a text attribute

Not all id3 types have a text attribute (such as mutagen.id3.APIC or
mutagen.id3.UFID). This leads to the get_meta helper to crash when
trying to access the text attribute of an object which does not have it.
Fixes it by checking the text attribute is available before accessing
it.

Signed-off-by: Antoine Tenart <antoine.tenart@ack.tf>
---
 libmat2/audio.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libmat2/audio.py b/libmat2/audio.py
index bfe7f79..d7d02cd 100644
--- a/libmat2/audio.py
+++ b/libmat2/audio.py
@@ -38,6 +38,8 @@ class MP3Parser(MutagenParser):
         metadata = {}  # type: Dict[str, Union[str, dict]]
         meta = mutagen.File(self.filename).tags
         for key in meta:
+            if not hasattr(meta[key], 'text'):
+                continue
             metadata[key.rstrip(' \t\r\n\0')] = ', '.join(map(str, meta[key].text))
         return metadata
 
-- 
GitLab