Skip to content

Commit c53f58b

Browse files
support Deluge 2.0 and Python3
- bump version to 0.2
1 parent d049ca9 commit c53f58b

File tree

11 files changed

+636
-19
lines changed

11 files changed

+636
-19
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ supposed to reach public trackers.
1010

1111
Besides manually creating the default tracker list, you can also load it (periodically) from a URL.
1212

13+
This plugin is compatible with Deluge 1.3 and 2.0, Python2 2.7 and Python3 3.5+.
14+
1315
## Installation
1416

1517
* create the egg with
@@ -18,6 +20,8 @@ Besides manually creating the default tracker list, you can also load it (period
1820

1921
(or try to use [the one from the "egg" directory][2] - be careful to install the py2.7 version of Deluge, if you're using Windows)
2022

23+
* you need to use the same version of Python as the one that Deluge is running under.
24+
2125
* add it to Deluge from Preferences -> Plugins -> Install Plugin
2226

2327
## Troubleshooting

defaulttrackers/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# __init__.py
33
#
4-
# Copyright (C) 2013-2016 Stefan Talpalaru <[email protected]>
4+
# Copyright (C) 2013-2019 Stefan Talpalaru <[email protected]>
55
#
66
# Basic plugin template created by:
77
# Copyright (C) 2008 Martijn Voncken <[email protected]>
@@ -38,22 +38,30 @@
3838
# statement from all source files in the program, then also delete it here.
3939
#
4040

41+
from __future__ import absolute_import
4142
from deluge.plugins.init import PluginInitBase
4243

4344
class CorePlugin(PluginInitBase):
4445
def __init__(self, plugin_name):
45-
from core import Core as _plugin_cls
46+
from .core import Core as _plugin_cls
4647
self._plugin_cls = _plugin_cls
4748
super(CorePlugin, self).__init__(plugin_name)
4849

4950
class GtkUIPlugin(PluginInitBase):
5051
def __init__(self, plugin_name):
51-
from gtkui import GtkUI as _plugin_cls
52+
from .gtkui import GtkUI as _plugin_cls
5253
self._plugin_cls = _plugin_cls
5354
super(GtkUIPlugin, self).__init__(plugin_name)
5455

56+
class Gtk3UIPlugin(PluginInitBase):
57+
def __init__(self, plugin_name):
58+
from .gtk3ui import Gtk3UI as _plugin_cls
59+
self._plugin_cls = _plugin_cls
60+
super(Gtk3UIPlugin, self).__init__(plugin_name)
61+
5562
class WebUIPlugin(PluginInitBase):
5663
def __init__(self, plugin_name):
57-
from webui import WebUI as _plugin_cls
64+
from .webui import WebUI as _plugin_cls
5865
self._plugin_cls = _plugin_cls
5966
super(WebUIPlugin, self).__init__(plugin_name)
67+

defaulttrackers/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# common.py
33
#
4-
# Copyright (C) 2013-2016 Stefan Talpalaru <[email protected]>
4+
# Copyright (C) 2013-2019 Stefan Talpalaru <[email protected]>
55
#
66
# Basic plugin template created by:
77
# Copyright (C) 2008 Martijn Voncken <[email protected]>
@@ -39,6 +39,8 @@
3939
#
4040

4141

42+
from __future__ import absolute_import, unicode_literals
43+
4244
def get_resource(filename):
4345
import pkg_resources, os
4446
return pkg_resources.resource_filename("defaulttrackers",

defaulttrackers/core.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# core.py
33
#
4-
# Copyright (C) 2013-2018 Ștefan Talpalaru <[email protected]>
4+
# Copyright (C) 2013-2019 Ștefan Talpalaru <[email protected]>
55
#
66
# Basic plugin template created by:
77
# Copyright (C) 2008 Martijn Voncken <[email protected]>
@@ -38,13 +38,14 @@
3838
# statement from all source files in the program, then also delete it here.
3939
#
4040

41+
from __future__ import absolute_import, unicode_literals
4142
import datetime
4243
import logging
4344
import re
4445
import ssl
4546
import time
4647
import traceback
47-
import urllib2
48+
import six
4849

4950
from deluge.common import is_url
5051
from deluge.core.rpcserver import export
@@ -94,13 +95,13 @@ def update_trackerlist_from_url(self):
9495
'Accept-Language': 'en-US,en;q=0.8',
9596
}
9697

97-
req = urllib2.Request(self.config["dynamic_trackerlist_url"], headers=headers)
98+
req = six.moves.urllib.request.Request(self.config["dynamic_trackerlist_url"], headers=headers)
9899
try:
99-
page = urllib2.urlopen(req, context=ssl._create_unverified_context()).read()
100+
page = six.moves.urllib.request.urlopen(req, context=ssl._create_unverified_context()).read()
100101
except:
101102
# maybe an older Python version without a "context" argument
102-
page = urllib2.urlopen(req).read()
103-
new_trackers = [url for url in re.findall(r'\w+://[\w\-.:/]+', page) if is_url(url)]
103+
page = six.moves.urllib.request.urlopen(req).read()
104+
new_trackers = [six.ensure_str(url) for url in re.findall(b'\w+://[\w\-.:/]+', page) if is_url(six.ensure_text(url))]
104105
if new_trackers:
105106
# replace all existing trackers
106107
self.config["trackers"] = []

0 commit comments

Comments
 (0)