'function to download a torrent by infohash and call a callback afterwards
with TorrentDef object as parameter.'

def _load_torrent(self, infohash):

    def add_to_loaded(infohash_str):
        '\n                                                function    to    add    loaded    infohash    to    memory\n                                                '
        self.loaded_torrent[unhexlify(infohash_str)].callback(TorrentDef.load_from_memory(self.session.get_collected_torrent(unhexlify(infohash_str))))
    if (infohash not in self.loaded_torrent):
        self.loaded_torrent[infohash] = defer.Deferred()
        if (not self.session.has_collected_torrent(infohash)):
            if self.session.has_download(infohash):
                return
            self.session.download_torrentfile(infohash, add_to_loaded, 0)
    deferred_load = self.loaded_torrent[infohash]
    return deferred_load
