diff options
Diffstat (limited to 'lib/strippers.py')
| -rw-r--r-- | lib/strippers.py | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/strippers.py b/lib/strippers.py index dfdf1ea..61030a7 100644 --- a/lib/strippers.py +++ b/lib/strippers.py | |||
| @@ -20,24 +20,42 @@ STRIPPERS = { | |||
| 20 | 'application/officeopenxml': office.OpenXmlStripper, | 20 | 'application/officeopenxml': office.OpenXmlStripper, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | try: # PDF support | 23 | |
| 24 | # PDF support | ||
| 25 | pdfSupport = True | ||
| 26 | try: | ||
| 24 | import poppler | 27 | import poppler |
| 28 | except ImportError: | ||
| 29 | print('Unable to import python-poppler: not PDF support') | ||
| 30 | pdfSupport = False | ||
| 31 | |||
| 32 | try: | ||
| 25 | import cairo | 33 | import cairo |
| 34 | except ImportError: | ||
| 35 | print('Unable to import python-cairo: no PDF support') | ||
| 36 | pdfSupport = False | ||
| 37 | |||
| 38 | try: | ||
| 26 | import pdfrw | 39 | import pdfrw |
| 40 | except ImportError: | ||
| 41 | print('Unable to import python-pdfrw: no PDf support') | ||
| 42 | pdfSupport = False | ||
| 43 | |||
| 44 | if pdfSupport: | ||
| 27 | STRIPPERS['application/x-pdf'] = office.PdfStripper | 45 | STRIPPERS['application/x-pdf'] = office.PdfStripper |
| 28 | STRIPPERS['application/pdf'] = office.PdfStripper | 46 | STRIPPERS['application/pdf'] = office.PdfStripper |
| 29 | except ImportError: | ||
| 30 | print('Unable to import python-poppler and/or python-cairo \ | ||
| 31 | and/or pdfrw: no PDF support') | ||
| 32 | 47 | ||
| 33 | try: # mutangen-python : audio format support | 48 | |
| 49 | # audio format support with mutagen-python | ||
| 50 | try: | ||
| 34 | import mutagen | 51 | import mutagen |
| 35 | STRIPPERS['audio/x-flac'] = audio.FlacStripper | 52 | STRIPPERS['audio/x-flac'] = audio.FlacStripper |
| 36 | STRIPPERS['audio/vorbis'] = audio.OggStripper | 53 | STRIPPERS['audio/vorbis'] = audio.OggStripper |
| 37 | except ImportError: | 54 | except ImportError: |
| 38 | print('Unable to import python-mutagen: limited audio format support') | 55 | print('Unable to import python-mutagen: limited audio format support') |
| 39 | 56 | ||
| 40 | try: # check if exiftool is installed on the system | 57 | # exiftool |
| 58 | try: | ||
| 41 | subprocess.Popen('exiftool', stdout=open('/dev/null')) | 59 | subprocess.Popen('exiftool', stdout=open('/dev/null')) |
| 42 | import exiftool | 60 | import exiftool |
| 43 | STRIPPERS['image/jpeg'] = exiftool.JpegStripper | 61 | STRIPPERS['image/jpeg'] = exiftool.JpegStripper |
