File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
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
47
47
48
DEFAULT_PREFS = {
48
49
"trackers" : [
49
50
#{"url": "test"},
50
51
],
52
+ # "dynamic_trackerlist":"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt",
51
53
}
52
54
53
55
log = logging .getLogger (__name__ )
@@ -67,14 +69,25 @@ def disable(self):
67
69
def update (self ):
68
70
pass
69
71
72
+ 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
77
+
70
78
def on_torrent_added (self , torrent_id , from_state = False ):
71
79
torrent = component .get ("TorrentManager" )[torrent_id ]
72
80
if (torrent .torrent_info and torrent .torrent_info .priv ()) or torrent .get_status (["private" ])["private" ]:
73
81
return
74
82
trackers = list (torrent .get_status (["trackers" ])["trackers" ])
75
83
existing_urls = [tracker ["url" ] for tracker in trackers ]
84
+ if "dynamic_trackerlist" in self .config :
85
+ if self .config ["dynamic_trackerlist" ]:
86
+ self .update_trackerlist ()
87
+ else :
88
+ self .config ["dynamic_trackers" ] = []
76
89
got_new_trackers = False
77
- for new_tracker in self .config ["trackers" ]:
90
+ for new_tracker in self .config ["trackers" ]+ self . config [ "dynamic_trackers" ] :
78
91
if new_tracker ["url" ] not in existing_urls :
79
92
got_new_trackers = True
80
93
trackers .append ({
You can’t perform that action at this time.
0 commit comments