File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 4343import deluge .component as component
4444import deluge .configmanager
4545from deluge .core .rpcserver import export
46- import urllib2
46+ from urllib2 import urlopen
47+ from time import time
4748
4849DEFAULT_PREFS = {
4950 "trackers" : [
5556log = logging .getLogger (__name__ )
5657
5758class Core (CorePluginBase ):
59+ LAST_DYNAMIC_TRACKERS_UPDATE = 0
5860 def enable (self ):
5961 self .config = deluge .configmanager .ConfigManager ("defaulttrackers.conf" , DEFAULT_PREFS )
6062 component .get ("EventManager" ).register_event_handler (
@@ -70,10 +72,12 @@ def update(self):
7072 pass
7173
7274 def update_trackerlist (self ):
73- trackers = urllib2 .urlopen (self .config ["dynamic_trackerlist" ]).read ()
74- trackers = [ {"url" :n } for n in trackers .split ("\n \n " ) if n ]
75- self .config ["dynamic_trackers" ] = trackers
76- del trackers
75+ if time ()- self .LAST_DYNAMIC_TRACKERS_UPDATE > 3600 :
76+ trackers = urlopen (self .config ["dynamic_trackerlist" ]).read ()
77+ trackers = [ {"url" :n } for n in trackers .split ("\n " ) if n ]
78+ self .config ["dynamic_trackers" ] = trackers
79+ del trackers
80+ self .LAST_DYNAMIC_TRACKERS_UPDATE = time ()
7781
7882 def on_torrent_added (self , torrent_id , from_state = False ):
7983 torrent = component .get ("TorrentManager" )[torrent_id ]
You can’t perform that action at this time.
0 commit comments