@@ -86,27 +86,28 @@ def update_trackerlist_from_url(self):
8686 now = datetime .datetime .utcnow ()
8787 last_update = datetime .datetime .utcfromtimestamp (self .config ["last_dynamic_trackers_update" ])
8888 if now - last_update > datetime .timedelta (days = self .config ["dynamic_trackers_update_interval" ]):
89+ combined_trackers = []
8990 try :
90- headers = {
91+ for url_line in self .config ["dynamic_trackerlist_url" ].splitlines ():
92+ url_line = url_line .strip ()
93+ if not url_line :
94+ continue
95+ headers = {
9196 'User-Agent' : 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0' ,
9297 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ,
9398 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' ,
9499 'Accept-Encoding' : 'none' ,
95100 'Accept-Language' : 'en-US,en;q=0.8' ,
96- }
97-
98- req = urllib .request .Request (self .config ["dynamic_trackerlist_url" ], headers = headers )
99- try :
100- page = urllib .request .urlopen (req , context = ssl ._create_unverified_context ()).read ()
101- except :
102- # maybe an older Python version without a "context" argument
103- page = urllib .request .urlopen (req ).read ()
104- new_trackers = [decode_bytes (url ) for url in re .findall (rb'\w+://[\w\-.:/]+' , page ) if is_url (decode_bytes (url ))]
105- if new_trackers :
106- # replace all existing trackers
107- self .config ["trackers" ] = []
108- for new_tracker in new_trackers :
109- self .config ["trackers" ].append ({"url" : new_tracker })
101+ }
102+ req = urllib .request .Request (url_line , headers = headers )
103+ try :
104+ page = urllib .request .urlopen (req , context = ssl ._create_unverified_context ()).read ()
105+ except :
106+ page = urllib .request .urlopen (req ).read ()
107+ found = [decode_bytes (u ) for u in re .findall (rb'\w+://[\w\-.:/]+' , page ) if is_url (decode_bytes (u ))]
108+ combined_trackers .extend (found )
109+ if combined_trackers :
110+ self .config ["trackers" ] = [{"url" : t } for t in combined_trackers ]
110111 self .config ["last_dynamic_trackers_update" ] = time .mktime (now .timetuple ())
111112 except :
112113 traceback .print_exc ()
0 commit comments