diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-06-10 16:58:21 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2018-06-26 12:42:26 +0100 |
commit | 633c56f54ecb5733aa29670273c6d5f88db404ad (patch) | |
tree | 5cf48a416df5c8bd41313a017ff3346c84d3ec76 /deluge/core/core.py | |
parent | 23171ad20500d668ff43494b54e9da55a921bb5b (diff) | |
download | deluge-633c56f54ecb5733aa29670273c6d5f88db404ad.tar.gz deluge-633c56f54ecb5733aa29670273c6d5f88db404ad.tar.bz2 deluge-633c56f54ecb5733aa29670273c6d5f88db404ad.zip |
[Core] Add prefetch metadata methods for magnets
Diffstat (limited to 'deluge/core/core.py')
-rw-r--r-- | deluge/core/core.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py index 00266fac2..387e32488 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -404,6 +404,26 @@ class Core(component.Component): return d @export + def prefetch_magnet_metadata(self, magnet, timeout=60): + """Download the metadata for the magnet uri without adding torrent to deluge session. + + Args: + magnet (str): The magnet uri. + timeout (int): Time to wait to recieve metadata from peers. + + Returns: + Deferred: A tuple of (torrent_id (str), metadata (bytes)) for the magnet. + + The metadata is base64 encoded. + + """ + def on_metadata(result): + torrent_id, metadata = result + return torrent_id, b64encode(metadata) + + return self.torrentmanager.prefetch_metadata(magnet, timeout).addCallback(on_metadata) + + @export def add_torrent_file(self, filename, filedump, options): """Adds a torrent file to the session. |