def getTorrent(self): param = { 'save_path': self.current_dir, 'duplicate_is_error': True, 'storage_mode': libtorrent.storage_mode_t.storage_mode_allocate, } torrent_handle = libtorrent.add_magnet_uri(self.session, self.magnet_url, param) print 'Start Downloading metadata' found = False #counting time start_time = time.time() while True: if torrent_handle.has_metadata(): found = True break time.sleep(2) #if getting torrent longer than 60 secs. Stop to find the torrent if not (time.time() - start_time) <= 60: found = False break print 'Each 2 sec. Download Speed is : %f' % (libtorrent.peer_info().down_speed) continue if found: print 'Downloaded Success' torrent_info = torrent_handle.get_torrent_info() f_s = libtorrent.file_storage() #merge torrent files for i in torrent_info.files(): f_s.add_file(i) files = libtorrent.create_torrent(f_s) files.set_comment(torrent_info.comment()) files.set_creator(torrent_info.creator()) #encode to binary torrent_binary = libtorrent.bencode(files.generate()) #get torrent name torrent_name = torrent_info.name() self.openFile(torrent_binary , torrent_name) else: print 'Time Out'
def test_peer_info_members(self): p = lt.peer_info() print(p.client) print(p.pieces) print(p.pieces) print(p.last_request) print(p.last_active) print(p.flags) print(p.source) print(p.pid) print(p.downloading_piece_index) print(p.ip) print(p.local_endpoint) print(p.read_state) print(p.write_state)