diff options
| author | Antoine Tenart | 2019-03-22 16:33:59 +0100 |
|---|---|---|
| committer | jvoisin | 2019-03-23 00:32:44 +0100 |
| commit | 0e3c2c9b1b4fbfdf38dd675e2ce112925f5f278d (patch) | |
| tree | 502fa99806afb7021bd19ec1a20f0ebc319b7c49 /libmat2 | |
| parent | 2dc097baf326bfdb1c09d7a50db72a42b278cbe9 (diff) | |
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>
Diffstat (limited to 'libmat2')
| -rw-r--r-- | libmat2/audio.py | 2 |
1 files changed, 2 insertions, 0 deletions
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): | |||
| 38 | metadata = {} # type: Dict[str, Union[str, dict]] | 38 | metadata = {} # type: Dict[str, Union[str, dict]] |
| 39 | meta = mutagen.File(self.filename).tags | 39 | meta = mutagen.File(self.filename).tags |
| 40 | for key in meta: | 40 | for key in meta: |
| 41 | if not hasattr(meta[key], 'text'): | ||
| 42 | continue | ||
| 41 | metadata[key.rstrip(' \t\r\n\0')] = ', '.join(map(str, meta[key].text)) | 43 | metadata[key.rstrip(' \t\r\n\0')] = ', '.join(map(str, meta[key].text)) |
| 42 | return metadata | 44 | return metadata |
| 43 | 45 | ||
