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 4343import deluge .component as component
4444import deluge .configmanager
4545from deluge .core .rpcserver import export
46+ import urllib2
4647
4748DEFAULT_PREFS = {
4849 "trackers" : [
4950 #{"url": "test"},
5051 ],
52+ # "dynamic_trackerlist":"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt",
5153}
5254
5355log = logging .getLogger (__name__ )
@@ -67,14 +69,25 @@ def disable(self):
6769 def update (self ):
6870 pass
6971
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+
7078 def on_torrent_added (self , torrent_id , from_state = False ):
7179 torrent = component .get ("TorrentManager" )[torrent_id ]
7280 if (torrent .torrent_info and torrent .torrent_info .priv ()) or torrent .get_status (["private" ])["private" ]:
7381 return
7482 trackers = list (torrent .get_status (["trackers" ])["trackers" ])
7583 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" ] = []
7689 got_new_trackers = False
77- for new_tracker in self .config ["trackers" ]:
90+ for new_tracker in self .config ["trackers" ]+ self . config [ "dynamic_trackers" ] :
7891 if new_tracker ["url" ] not in existing_urls :
7992 got_new_trackers = True
8093 trackers .append ({
You can’t perform that action at this time.
0 commit comments