fix except clauses in bookmedia
authorJan Szejko <janek37@gmail.com>
Wed, 19 Oct 2016 11:36:24 +0000 (13:36 +0200)
committerJan Szejko <janek37@gmail.com>
Wed, 19 Oct 2016 11:36:24 +0000 (13:36 +0200)
src/catalogue/models/bookmedia.py

index 1f984a0..39ebf49 100644 (file)
@@ -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