diff options
| author | jvoisin | 2011-07-27 16:37:59 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-27 16:37:59 +0200 |
| commit | 37ba35d1b2361b742f5aeab1ed7a202a54052a43 (patch) | |
| tree | fe164f9b1879660d59873503259724993cd044ed /lib/mat.py | |
| parent | 52803d469598b5ab99f8e1cd6c2e125a45ae0fd7 (diff) | |
Add ogg support
Diffstat (limited to 'lib/mat.py')
| -rw-r--r-- | lib/mat.py | 19 |
1 files changed, 15 insertions, 4 deletions
| @@ -39,17 +39,29 @@ STRIPPERS = { | |||
| 39 | try: | 39 | try: |
| 40 | import mutagen | 40 | import mutagen |
| 41 | STRIPPERS['audio/x-flac'] = audio.FlacStripper | 41 | STRIPPERS['audio/x-flac'] = audio.FlacStripper |
| 42 | STRIPPERS['audio/x-ape'] = audio.Apev2Stripper | ||
| 43 | STRIPPERS['audio/x-wavpack'] = audio.Apev2Stripper | ||
| 44 | STRIPPERS['audio/vorbis'] = audio.OggStripper | ||
| 42 | except ImportError: | 45 | except ImportError: |
| 43 | print('unable to import python-mutagen : limited audio format support') | 46 | print('unable to import python-mutagen : limited audio format support') |
| 44 | 47 | ||
| 48 | |||
| 45 | def secure_remove(filename): | 49 | def secure_remove(filename): |
| 46 | ''' | 50 | ''' |
| 47 | securely remove the file | 51 | securely remove the file |
| 48 | ''' | 52 | ''' |
| 53 | removed = False | ||
| 49 | try: | 54 | try: |
| 50 | subprocess.call('shred --remove %s' % filename, shell=True) | 55 | subprocess.call('shred --remove %s' % filename, shell=True) |
| 56 | removed = True | ||
| 51 | except: | 57 | except: |
| 52 | logging.error('Unable to remove %s' % filename) | 58 | logging.error('Unable to securely remove %s' % filename) |
| 59 | |||
| 60 | if removed is False: | ||
| 61 | try: | ||
| 62 | os.remove(filename) | ||
| 63 | except: | ||
| 64 | logging.error('Unable to remove %s' % filename) | ||
| 53 | 65 | ||
| 54 | 66 | ||
| 55 | def is_secure(filename): | 67 | def is_secure(filename): |
| @@ -72,8 +84,6 @@ def create_class_file(name, backup, add2archive): | |||
| 72 | return | 84 | return |
| 73 | 85 | ||
| 74 | filename = '' | 86 | filename = '' |
| 75 | realname = name | ||
| 76 | |||
| 77 | try: | 87 | try: |
| 78 | filename = hachoir_core.cmd_line.unicodeFilename(name) | 88 | filename = hachoir_core.cmd_line.unicodeFilename(name) |
| 79 | except TypeError: # get rid of "decoding Unicode is not supported" | 89 | except TypeError: # get rid of "decoding Unicode is not supported" |
| @@ -85,6 +95,7 @@ def create_class_file(name, backup, add2archive): | |||
| 85 | return | 95 | return |
| 86 | 96 | ||
| 87 | mime = parser.mime_type | 97 | mime = parser.mime_type |
| 98 | print mime | ||
| 88 | 99 | ||
| 89 | if mime.startswith('application/vnd.oasis.opendocument'): | 100 | if mime.startswith('application/vnd.oasis.opendocument'): |
| 90 | mime = 'application/vnd.oasis.opendocument' # opendocument fileformat | 101 | mime = 'application/vnd.oasis.opendocument' # opendocument fileformat |
| @@ -92,7 +103,7 @@ def create_class_file(name, backup, add2archive): | |||
| 92 | try: | 103 | try: |
| 93 | stripper_class = STRIPPERS[mime] | 104 | stripper_class = STRIPPERS[mime] |
| 94 | except KeyError: | 105 | except KeyError: |
| 95 | logging.info('Don\'t have stripper for %s\' format' % filename) | 106 | logging.info('Don\'t have stripper for %s\'s format' % name) |
| 96 | return | 107 | return |
| 97 | 108 | ||
| 98 | return stripper_class(filename, parser, mime, backup, add2archive) | 109 | return stripper_class(filename, parser, mime, backup, add2archive) |
