summaryrefslogtreecommitdiff
path: root/src/audio.py
diff options
context:
space:
mode:
authorjvoisin2018-03-31 15:46:17 +0200
committerjvoisin2018-03-31 15:46:17 +0200
commitf391c9603c36a8ec80942c23ac6ba39fca5df72a (patch)
tree7fdc2053c01f103a675274ebd3e6abcffba4dfbe /src/audio.py
parent088c3d013ce4515920dea5e0becb98b36afa9a31 (diff)
Change a bit the source code organisation
Diffstat (limited to 'src/audio.py')
-rw-r--r--src/audio.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/audio.py b/src/audio.py
new file mode 100644
index 0000000..4da298c
--- /dev/null
+++ b/src/audio.py
@@ -0,0 +1,37 @@
1import subprocess
2import shutil
3import json
4
5import mutagen
6
7from . import abstract
8
9class MutagenParser(abstract.AbstractParser):
10 def get_meta(self):
11 f = mutagen.File(self.filename)
12 if f.tags:
13 return f.tags
14 return {}
15
16 def remove_all(self):
17 shutil.copy(self.filename, self.output_filename)
18 f = mutagen.File(self.output_filename)
19 f.delete()
20 f.save()
21 return True
22
23class MP3Parser(MutagenParser):
24 mimetypes = {'audio/mpeg', }
25
26 def get_meta(self):
27 meta = super().get_meta()
28 metadata = {}
29 for key in meta:
30 metadata[key] = meta[key].text
31 return metadata
32
33class OGGParser(MutagenParser):
34 mimetypes = {'audio/ogg', }
35
36class FLACParser(MutagenParser):
37 mimetypes = {'audio/flac', }