Skip to content

Commit 8bcddd1

Browse files
author
Tobi Sim
committed
added dynamic trackerlist support
1 parent 7d7800c commit 8bcddd1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

defaulttrackers/core.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
import deluge.component as component
4444
import deluge.configmanager
4545
from deluge.core.rpcserver import export
46+
import urllib2
4647

4748
DEFAULT_PREFS = {
4849
"trackers": [
4950
#{"url": "test"},
5051
],
52+
# "dynamic_trackerlist":"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt",
5153
}
5254

5355
log = 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({

0 commit comments

Comments
 (0)