summaryrefslogtreecommitdiff
path: root/lib/strippers.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/strippers.py')
-rw-r--r--lib/strippers.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/strippers.py b/lib/strippers.py
new file mode 100644
index 0000000..7d27874
--- /dev/null
+++ b/lib/strippers.py
@@ -0,0 +1,48 @@
1'''
2 Manage which fileformat can be processed
3'''
4
5import images
6import audio
7import office
8import archive
9import misc
10import subprocess
11
12STRIPPERS = {
13 'application/x-tar': archive.TarStripper,
14 'application/x-gzip': archive.GzipStripper,
15 'application/x-bzip2': archive.Bzip2Stripper,
16 'application/zip': archive.ZipStripper,
17 'audio/mpeg': audio.MpegAudioStripper,
18 'application/x-bittorrent': misc.TorrentStripper,
19 'application/opendocument': office.OpenDocumentStripper,
20 'application/officeopenxml': office.OpenXmlStripper,
21}
22
23try: # PDF support
24 import poppler
25 import cairo
26 STRIPPERS['application/x-pdf'] = office.PdfStripper
27 STRIPPERS['application/pdf'] = office.PdfStripper
28except ImportError:
29 print('Unable to import python-poppler and/or python-cairo: no PDF \
30 support')
31
32try: # mutangen-python : audio format support
33 import mutagen
34 STRIPPERS['audio/x-flac'] = audio.FlacStripper
35 STRIPPERS['audio/vorbis'] = audio.OggStripper
36except ImportError:
37 print('Unable to import python-mutagen: limited audio format support')
38
39try: # check if exiftool is installed on the system
40 subprocess.Popen('exiftool', stdout=open('/dev/null'))
41 import exiftool
42 STRIPPERS['image/jpeg'] = exiftool.JpegStripper
43 STRIPPERS['image/png'] = exiftool.PngStripper
44except: # if exiftool is not installed, use hachoir
45 print('Unable to find exiftool: limited images support')
46 STRIPPERS['image/jpeg'] = images.JpegStripper
47 STRIPPERS['image/png'] = images.PngStripper
48