summaryrefslogtreecommitdiff
path: root/libmat/audio.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmat/audio.py')
-rw-r--r--libmat/audio.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/libmat/audio.py b/libmat/audio.py
index dae9d75..2747dc1 100644
--- a/libmat/audio.py
+++ b/libmat/audio.py
@@ -1,5 +1,5 @@
1''' Care about audio fileformat 1""" Care about audio fileformat
2''' 2"""
3 3
4try: 4try:
5 from mutagen.flac import FLAC 5 from mutagen.flac import FLAC
@@ -12,41 +12,41 @@ import mutagenstripper
12 12
13 13
14class MpegAudioStripper(parser.GenericParser): 14class MpegAudioStripper(parser.GenericParser):
15 ''' Represent mpeg audio file (mp3, ...) 15 """ Represent mpeg audio file (mp3, ...)
16 ''' 16 """
17 def _should_remove(self, field): 17 def _should_remove(self, field):
18 return field.name in ("id3v1", "id3v2") 18 return field.name in ("id3v1", "id3v2")
19 19
20 20
21class OggStripper(mutagenstripper.MutagenStripper): 21class OggStripper(mutagenstripper.MutagenStripper):
22 ''' Represent an ogg vorbis file 22 """ Represent an ogg vorbis file
23 ''' 23 """
24 def _create_mfile(self): 24 def _create_mfile(self):
25 self.mfile = OggVorbis(self.filename) 25 self.mfile = OggVorbis(self.filename)
26 26
27 27
28class FlacStripper(mutagenstripper.MutagenStripper): 28class FlacStripper(mutagenstripper.MutagenStripper):
29 ''' Represent a Flac audio file 29 """ Represent a Flac audio file
30 ''' 30 """
31 def _create_mfile(self): 31 def _create_mfile(self):
32 self.mfile = FLAC(self.filename) 32 self.mfile = FLAC(self.filename)
33 33
34 def remove_all(self): 34 def remove_all(self):
35 ''' Remove the "metadata" block from the file 35 """ Remove the "metadata" block from the file
36 ''' 36 """
37 super(FlacStripper, self).remove_all() 37 super(FlacStripper, self).remove_all()
38 self.mfile.clear_pictures() 38 self.mfile.clear_pictures()
39 self.mfile.save() 39 self.mfile.save()
40 return True 40 return True
41 41
42 def is_clean(self): 42 def is_clean(self):
43 ''' Check if the "metadata" block is present in the file 43 """ Check if the "metadata" block is present in the file
44 ''' 44 """
45 return super(FlacStripper, self).is_clean() and not self.mfile.pictures 45 return super(FlacStripper, self).is_clean() and not self.mfile.pictures
46 46
47 def get_meta(self): 47 def get_meta(self):
48 ''' Return the content of the metadata block if present 48 """ Return the content of the metadata block if present
49 ''' 49 """
50 metadata = super(FlacStripper, self).get_meta() 50 metadata = super(FlacStripper, self).get_meta()
51 if self.mfile.pictures: 51 if self.mfile.pictures:
52 metadata['picture:'] = 'yes' 52 metadata['picture:'] = 'yes'