commit 2a6d844925f841aaf6cd20cd819281c82eb43839
Author: David Bartley <andareed@gmail.com>
Date: Sat Mar 23 15:03:07 2013 -0700
Fix the extractor plugin so that it works with rar and similar files that end with .foo.rar.
diff --git a/deluge/plugins/Extractor/deluge/plugins/extractor/core.py b/deluge/plugins/Extractor/deluge/plugins/extractor/core.py
index f8ccb0b..c03ec8d 100644
a
|
b
|
def _on_torrent_finished(self, torrent_id):
|
133 | 133 | |
134 | 134 | files = tid.get_files() |
135 | 135 | for f in files: |
136 | | cmd = '' |
137 | | file_ext = os.path.splitext(os.path.splitext(f["path"])[0])[1] + os.path.splitext(f["path"])[1] |
138 | | if file_ext in EXTRACT_COMMANDS: |
139 | | cmd = EXTRACT_COMMANDS[file_ext] |
| 136 | matches = [cmd for (ext,cmd) in EXTRACT_COMMANDS.iteritems() if f["path"].endswith(ext)] |
| 137 | if matches: |
| 138 | cmd = matches[0] |
140 | 139 | else: |
141 | | log.error("Can't extract unknown file type: %s", file_ext) |
| 140 | log.error("Can't extract file with unknown file type: %s", f["path"]) |
142 | 141 | continue |
143 | 142 | |
144 | 143 | # Now that we have the cmd, lets run it to extract the files |
… |
… |
def on_extract_failed(result, torrent_id, fpath):
|
167 | 166 | log.error("Extract failed: %s (%s)", fpath, torrent_id) |
168 | 167 | |
169 | 168 | # Run the command and add some callbacks |
170 | | if cmd: |
171 | | log.debug("Extracting %s with %s %s to %s", fpath, cmd[0], cmd[1], dest) |
172 | | d = getProcessValue(cmd[0], cmd[1].split() + [str(fpath)], {}, str(dest)) |
173 | | d.addCallback(on_extract_success, torrent_id, fpath) |
174 | | d.addErrback(on_extract_failed, torrent_id, fpath) |
| 169 | log.debug("Extracting %s with %s %s to %s", fpath, cmd[0], cmd[1], dest) |
| 170 | d = getProcessValue(cmd[0], cmd[1].split() + [str(fpath)], {}, str(dest)) |
| 171 | d.addCallback(on_extract_success, torrent_id, fpath) |
| 172 | d.addErrback(on_extract_failed, torrent_id, fpath) |
175 | 173 | |
176 | 174 | @export |
177 | 175 | def set_config(self, config): |