Add ability to rename files prior to adding with the option "mapped_files" which is a dictionary of {index: filename, ...}

This commit is contained in:
Andrew Resch 2009-06-26 23:31:47 +00:00
parent 6fb180ed23
commit 0a9a6b4816
2 changed files with 7 additions and 0 deletions

View File

@ -75,6 +75,7 @@ class TorrentOptions(dict):
for opt_k, conf_k in options_conf_map.iteritems(): for opt_k, conf_k in options_conf_map.iteritems():
self[opt_k] = config[conf_k] self[opt_k] = config[conf_k]
self["file_priorities"] = [] self["file_priorities"] = []
self["mapped_files"] = {}
class Torrent: class Torrent:
"""Torrent holds information about torrents added to the libtorrent session. """Torrent holds information about torrents added to the libtorrent session.

View File

@ -340,6 +340,12 @@ class TorrentManager(component.Component):
o.update(options) o.update(options)
options = o options = o
# Check for renamed files and if so, rename them in the torrent_info
# before adding to the session.
if options["mapped_files"]:
for index, name in options["mapped_files"].items():
torrent_info.rename_file(index, name)
add_torrent_params["ti"] = torrent_info add_torrent_params["ti"] = torrent_info
add_torrent_params["resume_data"] = "" add_torrent_params["resume_data"] = ""