From: Jan Szejko Date: Wed, 19 Oct 2016 11:36:24 +0000 (+0200) Subject: fix except clauses in bookmedia X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/41c0fb950cf2b7b29a2106114247e9ca70f2609e?ds=inline fix except clauses in bookmedia --- diff --git a/src/catalogue/models/bookmedia.py b/src/catalogue/models/bookmedia.py index 1f984a044..39ebf496c 100644 --- a/src/catalogue/models/bookmedia.py +++ b/src/catalogue/models/bookmedia.py @@ -124,13 +124,13 @@ class BookMedia(models.Model): audio = id3.ID3(filepath) return [t.data for t in audio.getall('PRIV') if t.owner == 'wolnelektury.pl?flac_sha1'][0] - except MutagenError: + except (MutagenError, IndexError): return None elif filetype == 'ogg': try: audio = mutagen.File(filepath) return audio.get('flac_sha1', [None])[0] - except (MutagenError, AttributeError): + except (MutagenError, AttributeError, IndexError): return None else: return None