From 9a7b93928b344310fec4935a266223c0d9bd5fa7 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 26 Sep 2018 20:39:24 +0100 Subject: [PATCH] Didn't mean to commit this module yet. --- modules/torrent.py | 49 ---------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 modules/torrent.py diff --git a/modules/torrent.py b/modules/torrent.py deleted file mode 100644 index fdc3221d..00000000 --- a/modules/torrent.py +++ /dev/null @@ -1,49 +0,0 @@ -#--ignore - -import tempfile, time -import libtorrent - -def magnet(magnet): - #log.info("Opening session for link %s", url) - - session = libtorrent.session() - session.add_extension('ut_metadata') - session.add_extension('ut_pex') - session.add_extension('metadata_transfer') - session.add_dht_router("router.utorrent.com", 6881) - session.add_dht_router("router.bittorrent.com", 6881) - session.add_dht_router("dht.transmissionbt.com", 6881) - session.add_dht_router("dht.aelitis.com", 6881) - session.start_dht() - session.start_lsd() - session.start_upnp() - session.start_natpmp() - - params = {'save_path': "/dev/null", 'duplicate_is_error': True, - 'storage_mode': libtorrent.storage_mode_t(2), 'paused': False, - 'auto_managed': True} - handle = libtorrent.add_magnet_uri(session, magnet, params) - - #log.info("Waiting metadata") - has_metadata = False - for i in range(10): - if handle.has_metadata(): - print("yes!") - has_metadata = True - break - else: - time.sleep(1) - if not has_metadata: - print("no!") - #event["stderr"].write("Timed out getting magnet info") - return - session.pause() - - #log.info("Metadata retrieved") - torrent_info = handle.get_torrent_info() - print(dir(torrent_info)) - - session.remove_torrent(handle) - #log.info("Torrent file saved to %s", file_path) - -magnet("magnet:?xt=urn:btih:ea5938cbb6176a675a3e71682faf9801b5b6116f")