diff options
Diffstat (limited to 'lib/strippers.py')
| -rw-r--r-- | lib/strippers.py | 48 |
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 | |||
| 5 | import images | ||
| 6 | import audio | ||
| 7 | import office | ||
| 8 | import archive | ||
| 9 | import misc | ||
| 10 | import subprocess | ||
| 11 | |||
| 12 | STRIPPERS = { | ||
| 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 | |||
| 23 | try: # PDF support | ||
| 24 | import poppler | ||
| 25 | import cairo | ||
| 26 | STRIPPERS['application/x-pdf'] = office.PdfStripper | ||
| 27 | STRIPPERS['application/pdf'] = office.PdfStripper | ||
| 28 | except ImportError: | ||
| 29 | print('Unable to import python-poppler and/or python-cairo: no PDF \ | ||
| 30 | support') | ||
| 31 | |||
| 32 | try: # mutangen-python : audio format support | ||
| 33 | import mutagen | ||
| 34 | STRIPPERS['audio/x-flac'] = audio.FlacStripper | ||
| 35 | STRIPPERS['audio/vorbis'] = audio.OggStripper | ||
| 36 | except ImportError: | ||
| 37 | print('Unable to import python-mutagen: limited audio format support') | ||
| 38 | |||
| 39 | try: # 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 | ||
| 44 | except: # 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 | |||
