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 43
43
import deluge .component as component
44
44
import deluge .configmanager
45
45
from deluge .core .rpcserver import export
46
- import urllib2
46
+ from urllib2 import urlopen
47
+ from time import time
47
48
48
49
DEFAULT_PREFS = {
49
50
"trackers" : [
55
56
log = logging .getLogger (__name__ )
56
57
57
58
class Core (CorePluginBase ):
59
+ LAST_DYNAMIC_TRACKERS_UPDATE = 0
58
60
def enable (self ):
59
61
self .config = deluge .configmanager .ConfigManager ("defaulttrackers.conf" , DEFAULT_PREFS )
60
62
component .get ("EventManager" ).register_event_handler (
@@ -70,10 +72,12 @@ def update(self):
70
72
pass
71
73
72
74
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 ()
77
81
78
82
def on_torrent_added (self , torrent_id , from_state = False ):
79
83
torrent = component .get ("TorrentManager" )[torrent_id ]
You can’t perform that action at this time.
0 commit comments