Ticket #2290: deluge-extractor.patch

File deluge-extractor.patch, 2.2 KB (added by Andareed, 11 years ago)

Cleaner extractor fix

  • deluge/plugins/Extractor/deluge/plugins/extractor/core.py

    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): 
    133133 
    134134        files = tid.get_files() 
    135135        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] 
    140139            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"]) 
    142141                continue 
    143142 
    144143            # Now that we have the cmd, lets run it to extract the files 
    def on_extract_failed(result, torrent_id, fpath): 
    167166                log.error("Extract failed: %s (%s)", fpath, torrent_id) 
    168167 
    169168            # 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) 
    175173 
    176174    @export 
    177175    def set_config(self, config):