Making Deluge’s Execute Plugin Support Unicode

The Execute plugin that comes bundled with Deluge has a problem with Unicode characters such as à, é, ü, î, etc. So you’ll find that if you download a torrent that has those sorts of characters in its main name, or even file names, the Execute plugin handler will fail and your script will not run. The torrents will simply rest, completed, in Deluge. This is irritating.

Luckily, I have found a solution! Here’s what to do.

Edit this file: /usr/share/pyshared/deluge/plugins/Execute-1.2.egg/execute/core.py

Go to line 122 and modify the following (add-in the lines marked by the “+”):

# Go through and execute all the commands
        for command in self.config["commands"]:
            if command[EXECUTE_EVENT] == event:
                command = os.path.expandvars(command[EXECUTE_COMMAND])
                command = os.path.expanduser(command)
                log.debug("[execute] running %s", command)
+               if isinstance(torrent_name, unicode):
+                   torrent_name = torrent_name.encode('utf-8')
                d = getProcessOutputAndValue(command, (torrent_id, torrent_name, save_path), env=os.environ)
                d.addCallback(log_error, command)

Restart Deluge and it a try! Magic. Thankfully this fix will be found in version 1.3.6 so we won’t need to re-do it each time Deluge gets updated.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>