From b6a56501ec7fd4b73b1c84de0b91228b2ef5a45c Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sun, 2 Aug 2015 15:26:16 +0300 Subject: [PATCH] dht fix --- Libtorrent.py | 18 +++++++++--------- Player.py | 8 ++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Libtorrent.py b/Libtorrent.py index a57477a..1b70120 100644 --- a/Libtorrent.py +++ b/Libtorrent.py @@ -328,13 +328,13 @@ class Libtorrent: self.session = self.lt.session() self.session.set_alert_mask(self.lt.alert.category_t.error_notification | self.lt.alert.category_t.status_notification | self.lt.alert.category_t.storage_notification) #self.session.set_alert_mask(self.lt.alert.category_t.all_categories) - self.session.start_dht() self.session.add_dht_router("router.bittorrent.com", 6881) self.session.add_dht_router("router.utorrent.com", 6881) self.session.add_dht_router("router.bitcomet.com", 6881) - #self.session.start_lsd() - #self.session.start_upnp() - #self.session.start_natpmp() + self.session.start_dht() + self.session.start_lsd() + self.session.start_upnp() + self.session.start_natpmp() self.session.listen_on(6881, 6891) #tribler example never tested @@ -357,7 +357,7 @@ class Libtorrent: session_settings['rate_limit_ip_overhead'] = True session_settings['request_timeout'] = 1 session_settings['torrent_connect_boost'] = 100 - session_settings['user_agent'] = 'uTorrent/3430(40298)' + session_settings['user_agent'] = 'uTorrent/2200(24683)' #session_settings['cache_size'] = 0 #session_settings['use_read_cache'] = False @@ -373,7 +373,7 @@ class Libtorrent: session_settings.rate_limit_ip_overhead = True session_settings.request_timeout = 1 session_settings.torrent_connect_boost = 100 - session_settings.user_agent = 'uTorrent/3430(40298)' + session_settings.user_agent = 'uTorrent/2200(24683)' # self.session.set_settings(session_settings) @@ -456,9 +456,9 @@ class Libtorrent: self.session.remove_torrent(self.torrentHandle) except: log('RuntimeError: invalid torrent handle used') - #self.session.stop_natpmp() - #self.session.stop_upnp() - #self.session.stop_lsd() + self.session.stop_natpmp() + self.session.stop_upnp() + self.session.stop_lsd() self.session.stop_dht() def resume_data(self): diff --git a/Player.py b/Player.py index d20bbd5..b911065 100644 --- a/Player.py +++ b/Player.py @@ -235,8 +235,9 @@ class TorrentPlayer(xbmc.Player): for ind, title in subs: self.torrent.continueSession(ind) num_pieces = int(self.torrent.torrentFileInfo.num_pieces()) + xbmc.sleep(1000) + self.torrent.torrentHandle.force_dht_announce() while iterator < 100: - xbmc.sleep(1000) self.torrent.debug() downloadedSize = self.torrent.torrentHandle.file_progress()[self.contentId] status = self.torrent.torrentHandle.status() @@ -267,6 +268,7 @@ class TorrentPlayer(xbmc.Player): self.torrent.threadComplete = True self.torrent.checkThread() return + xbmc.sleep(1000) #self.torrent.torrentHandle.flush_cache() self.torrent.resume_data() self.torrent.session.remove_torrent(self.torrent.torrentHandle) @@ -352,7 +354,7 @@ class TorrentPlayer(xbmc.Player): playlist.add(path, listitem) xbmc.Player().play(playlist) - xbmc.sleep(3000) # very important, do not edit this, podavan + xbmc.sleep(2000) # very important, do not edit this, podavan return True def onPlayBackStarted(self): @@ -385,6 +387,8 @@ class TorrentPlayer(xbmc.Player): def loop(self): debug_counter=0 + xbmc.sleep(1000) + self.torrent.torrentHandle.force_dht_announce() with closing( OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay: with nested(self.attach(overlay.show, self.on_playback_paused),