|
44 | 44 | import ssl
|
45 | 45 | import time
|
46 | 46 | import traceback
|
47 |
| -import urllib2 |
| 47 | +import urllib.request, urllib.error, urllib.parse |
48 | 48 |
|
49 | 49 | from deluge.common import is_url
|
50 | 50 | from deluge.core.rpcserver import export
|
@@ -94,12 +94,12 @@ def update_trackerlist_from_url(self):
|
94 | 94 | 'Accept-Language': 'en-US,en;q=0.8',
|
95 | 95 | }
|
96 | 96 |
|
97 |
| - req = urllib2.Request(self.config["dynamic_trackerlist_url"], headers=headers) |
| 97 | + req = urllib.request.Request(self.config["dynamic_trackerlist_url"], headers=headers) |
98 | 98 | try:
|
99 |
| - page = urllib2.urlopen(req, context=ssl._create_unverified_context()).read() |
| 99 | + page = urllib.request.urlopen(req, context=ssl._create_unverified_context()).read() |
100 | 100 | except:
|
101 | 101 | # maybe an older Python version without a "context" argument
|
102 |
| - page = urllib2.urlopen(req).read() |
| 102 | + page = urllib.request.urlopen(req).read() |
103 | 103 | new_trackers = [url for url in re.findall(r'\w+://[\w\-.:/]+', page) if is_url(url)]
|
104 | 104 | if new_trackers:
|
105 | 105 | # replace all existing trackers
|
@@ -133,7 +133,7 @@ def on_torrent_added(self, torrent_id, from_state=False):
|
133 | 133 | @export
|
134 | 134 | def set_config(self, config):
|
135 | 135 | """Sets the config dictionary"""
|
136 |
| - for key in config.keys(): |
| 136 | + for key in list(config.keys()): |
137 | 137 | self.config[key] = config[key]
|
138 | 138 | self.config.save()
|
139 | 139 |
|
|
0 commit comments