summaryrefslogtreecommitdiff
path: root/libmat/audio.py
diff options
context:
space:
mode:
authorjvoisin2015-12-02 17:07:19 +0100
committerjvoisin2015-12-02 17:22:45 +0100
commit80ece3001895ea13d50915a5215fd47e313bab4c (patch)
treec5ede43867c5d7fe2af4178b34b0e6dc219f6aac /libmat/audio.py
parent3cf80e8b5d6faf410e9ad3aad77f23cf6418a587 (diff)
Remove hachoir from MAT.
This (huge) commit removes completely hachoir from MAT. Audio files are now processed with mutagen, and images with exiftool, since the main python imaging library (PIL) isn't super-great to deal with metadata (and damaged/non-standard files). Package maintainer should change the dependencies to reflect this.
Diffstat (limited to 'libmat/audio.py')
-rw-r--r--libmat/audio.py53
1 files changed, 0 insertions, 53 deletions
diff --git a/libmat/audio.py b/libmat/audio.py
deleted file mode 100644
index 2747dc1..0000000
--- a/libmat/audio.py
+++ /dev/null
@@ -1,53 +0,0 @@
1""" Care about audio fileformat
2"""
3
4try:
5 from mutagen.flac import FLAC
6 from mutagen.oggvorbis import OggVorbis
7except ImportError:
8 pass
9
10import parser
11import mutagenstripper
12
13
14class MpegAudioStripper(parser.GenericParser):
15 """ Represent mpeg audio file (mp3, ...)
16 """
17 def _should_remove(self, field):
18 return field.name in ("id3v1", "id3v2")
19
20
21class OggStripper(mutagenstripper.MutagenStripper):
22 """ Represent an ogg vorbis file
23 """
24 def _create_mfile(self):
25 self.mfile = OggVorbis(self.filename)
26
27
28class FlacStripper(mutagenstripper.MutagenStripper):
29 """ Represent a Flac audio file
30 """
31 def _create_mfile(self):
32 self.mfile = FLAC(self.filename)
33
34 def remove_all(self):
35 """ Remove the "metadata" block from the file
36 """
37 super(FlacStripper, self).remove_all()
38 self.mfile.clear_pictures()
39 self.mfile.save()
40 return True
41
42 def is_clean(self):
43 """ Check if the "metadata" block is present in the file
44 """
45 return super(FlacStripper, self).is_clean() and not self.mfile.pictures
46
47 def get_meta(self):
48 """ Return the content of the metadata block if present
49 """
50 metadata = super(FlacStripper, self).get_meta()
51 if self.mfile.pictures:
52 metadata['picture:'] = 'yes'
53 return metadata