deluge-webapi icon indicating copy to clipboard operation
deluge-webapi copied to clipboard

Add support for Deluge 2 - python 3.8

Open bluesky509 opened this issue 4 years ago • 28 comments

Please see here: https://forums.unraid.net/topic/44109-support-binhex-delugevpn/?do=findComment&comment=793371

this is all due to the fact that python 3.8 is now the latest stable release of python, sadly there is some catchup required with the developers to make their python modules 3.8 compatible, this also means certain deluge plugins (which are of course also written in python) are also not compatible with python 3.8 and thus may not work with the latest image.

bluesky509 avatar Dec 06 '19 11:12 bluesky509

I 1 up this, i hate the error on my nginx server

hitnrun30 avatar Jan 23 '20 16:01 hitnrun30

to make their python modules 3.8 compatible

Have no idea what's that about, since there was no backward incompatible changes 3.7->3.8. Please post here an actual error you have.

idlesign avatar Jan 24 '20 11:01 idlesign

I use organizr and it checks if something is in Deluge If I was able to add your webapi I would be fine but since I have Deluge 2 running against python 3.8 I get the below error.

2020/01/23 10:42:09 [error] 15236#6484: *53 FastCGI sent in stderr: "PHP Fatal error: Uncaught Exception: Method request returned an error (no. 2): Unknown method in C:\HTPC\nginx\html\Organizr2\api\functions\deluge.class.php:564 Stack trace: #0 C:\HTPC\nginx\html\Organizr2\api\functions\deluge.class.php(48): deluge->makeRequest('webapi.get_torr...', Array) #1 C:\HTPC\nginx\html\Organizr2\api\functions\homepage-connect-functions.php(1121): deluge->getTorrents(NULL, 'comment, downlo...') #2 C:\HTPC\nginx\html\Organizr2\api\functions\homepage-connect-functions.php(49): delugeConnect() #3 C:\HTPC\nginx\html\Organizr2\api\index.php(364): homepageConnect(Array) #4 {main} thrown in C:\HTPC\nginx\html\Organizr2\api\functions\deluge.class.php on line 564" while reading response header from upstream, client: 50.239.81.178, server: xxx.ddns.net, request: "POST /organizr2/api/?v1/homepage/connect HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.ddns.net", referrer: "https://xxx.ddns.net/organizr2/"

hitnrun30 avatar Jan 28 '20 14:01 hitnrun30

I get the below error.

Unfortunatelly this trace is not helpful, since it wrapped into organizr stuff. Please provide log from Deluge itself, so that we could investigate it.

idlesign avatar Jan 29 '20 03:01 idlesign

This what I get when I try ot add a plugin to deluge

11:37:53 [ERROR ][deluge.ui.web.json_api :79 ] Error calling method web.upload_plugin: [Errno 2] No such file or directory: 'C:\HTPC\Deluge2\Configuration\plugins\' 11:37:53 [ERROR ][deluge.ui.web.json_api :79 ] [Errno 2] No such file or directory: 'C:\HTPC\Deluge2\Configuration\plugins\' Traceback (most recent call last): File "C:\HTPC\Deluge2\lib\site-packages\deluge\ui\web\json_api.py", line 160, in _handle_request result = self._exec_local(method, params, request) File "C:\HTPC\Deluge2\lib\site-packages\deluge\ui\web\json_api.py", line 122, in _exec_local return meth(*params) File "C:\HTPC\Deluge2\lib\site-packages\deluge\ui\web\json_api.py", line 953, in upload_plugin shutil.copyfile(path, os.path.join(get_config_dir(), 'plugins', filename)) File "C:\HTPC\Deluge2\lib\shutil.py", line 121, in copyfile with open(dst, 'wb') as fdst: FileNotFoundError: [Errno 2] No such file or directory: 'C:\HTPC\Deluge2\Configuration\plugins\'

hitnrun30 avatar Jan 30 '20 15:01 hitnrun30

This what I get when I try ot add a plugin to deluge

In the trace I can see nothing specific to webapi. Check whether other plugins can be installed at all.

idlesign avatar Jan 31 '20 05:01 idlesign

no they can't this is so weird. Any help would be great.

hitnrun30 avatar Feb 03 '20 13:02 hitnrun30

Please try to apply to Deluge support forum: https://forum.deluge-torrent.org

idlesign avatar Feb 04 '20 03:02 idlesign

@aircave I had the same issue with deluge not recognizing the plugin, even though it was in the plugins folder but after seeing that deluge was running on python 3.8.2 I decided to build the .egg file using that version, which made it work. Maybe try renaming to WebAPI-0.4.0-py3.8.egg and see if you can trick deluge into accepting it

Mycsina avatar Mar 25 '20 23:03 Mycsina

@aircave could you possibly post the egg file you build? A friend is asking for it, but i'm not a python guy.

quorn23 avatar Apr 04 '20 22:04 quorn23

@aircave could you possibly post the egg file you build? A friend is asking for it, but i'm not a python guy.

@Mycsina ...Question above was for you.

I gave up and switched Transmission.

bluesky509 avatar Apr 05 '20 02:04 bluesky509

Sorry for the late response @quorn23! Here's's a freshly built one WebAPI-0.4.0-py3.8.zip

Mycsina avatar Apr 09 '20 22:04 Mycsina

@Mycsina no worries at all, much appreciated, forwarding it to my friend with Deluge.

Edit: Quick feedback, Mycsinas egg works perfectly with Deluge 2.0.4.dev23

quorn23 avatar Apr 09 '20 22:04 quorn23

@Mycsina no worries at all, much appreciated, forwarding it to my friend with Deluge.

Edit: Quick feedback, Mycsinas egg works perfectly with Deluge 2.0.4.dev23

I'm just getting the box bouncing back when I try to check it. Permissions OK, out of ideas...

niXta1 avatar Apr 12 '20 00:04 niXta1

@niXta1 Try to manually enable the plugin on one of the deluge conf files after closing it and then open it to see if it persists. When I was trying to use the 3.7 .egg plugin with Deluge running on 3.8 Python it simply wouldn't recognize, so check what Python version is deluge running on.

Mycsina avatar Apr 12 '20 02:04 Mycsina

@niXta1 Try to manually enable the plugin on one of the deluge conf files after closing it and then open it to see if it persists. When I was trying to use the 3.7 .egg plugin with Deluge running on 3.8 Python it simply wouldn't recognize, so check what Python version is deluge running on.

Ok, closing deluge and editing the conf. ended up in that it got disabled anyway at start. Im running on binhex, so it should be v3.8.

niXta1 avatar Apr 13 '20 09:04 niXta1

Just a reminder that to enable plugins in Deluge, you need to add their names to core.conf under enabled_plugins and restart.

Source

Zachar2 avatar Apr 13 '20 09:04 Zachar2

Just a reminder that to enable plugins in Deluge, you need to add their names to core.conf under enabled_plugins and restart.

Source

Yes:

   "download_location_paths_list": [],
    "enabled_plugins": [
        "LabelPlus",
        "AutoAdd",
        "Scheduler",
        "WebAPI"
    ],
    "enc_in_policy": 1,
    "enc_level": 1,
    "enc_out_policy": 1,
    "enc_prefer_rc4": true,
    "geoip_db_location": "/usr/share/GeoIP/GeoIP.dat",
    "ignore_limits_on_local_network": false,
    "info_sent": 0.0,

Error log:

22:10:19.116 [INFO    ][webapi.core                   :20  ] Enabling WebAPI plugin CORE ...
22:10:19.116 [INFO    ][webapi.core                   :57  ] Patching webui for CORS...
22:10:19.117 [ERROR   ][deluge.pluginmanagerbase      :193 ] Failed to start plugin: WebAPI
Traceback: <class 'KeyError'>: 'JSON'
/usr/lib/python3.8/site-packages/twisted/internet/defer.py:151:maybeDeferred
/usr/lib/python3.8/site-packages/deluge/plugins/init.py:27:enable
/config/plugins/WebAPI-0.4.0-py3.8.egg/webapi/core.py:26:enable
/config/plugins/WebAPI-0.4.0-py3.8.egg/webapi/core.py:59:patch_web_ui
/usr/lib/python3.8/site-packages/deluge/component.py:489:get

22:10:19.117 [INFO    ][webapi.core                   :29  ] Disabling WebAPI plugin CORE ...
22:10:19.117 [WARNING ][deluge.pluginmanagerbase      :246 ] Problems occured disabling plugin: WebAPI

niXta1 avatar Apr 15 '20 21:04 niXta1

<class 'KeyError'>: 'JSON' It doesn't relate to webapi per se. It means that JSON component of Deluge is not available for some reason. Try to digg that way.

idlesign avatar Apr 16 '20 00:04 idlesign

<class 'KeyError'>: 'JSON' It doesn't relate to webapi per se. It means that JSON component of Deluge is not available for some reason. Try to digg that way.

Progress, thanks! Can you give me more hints? Is the JSON component a basic Deluge component or where does it come from?

niXta1 avatar Apr 16 '20 09:04 niXta1

I see that JSON component is defined in https://git.deluge-torrent.org/deluge/tree/deluge/ui/web/json_api.py and is available with Deluge Web JSON-RPC API: https://deluge.readthedocs.io/en/latest/reference/webapi.html

idlesign avatar Apr 16 '20 09:04 idlesign

I've now added WebUi in the core.conf, still get the same error though...

19:48:09.100 [INFO    ][webapi.core                   :20  ] Enabling WebAPI plugin CORE ...
19:48:09.100 [INFO    ][webapi.core                   :57  ] Patching webui for CORS...
19:48:09.100 [ERROR   ][deluge.pluginmanagerbase      :193 ] Failed to start plugin: WebAPI
Traceback: <class 'KeyError'>: 'JSON'
/usr/lib/python3.8/site-packages/twisted/internet/defer.py:151:maybeDeferred
/usr/lib/python3.8/site-packages/deluge/plugins/init.py:27:enable
/config/plugins/WebAPI-0.4.0-py3.8.egg/webapi/core.py:26:enable
/config/plugins/WebAPI-0.4.0-py3.8.egg/webapi/core.py:59:patch_web_ui
/usr/lib/python3.8/site-packages/deluge/component.py:489:get

19:48:09.100 [INFO    ][webapi.core                   :29  ] Disabling WebAPI plugin CORE ...
19:48:09.100 [WARNING ][deluge.pluginmanagerbase      :246 ] Problems occured disabling plugin: WebAPI

niXta1 avatar Apr 19 '20 18:04 niXta1

Is it docker? If so to troubleshoot it further you may want first to try to reproduce the behaviour outside of docker.

idlesign avatar Apr 29 '20 06:04 idlesign

@niXta1 The WebAPI plugin works on 1st start. It fails on subsequent starts. I noticed that it generates the WebAPI.conf. In the deluged.log file, you'll notice that the plugin fails to start after it tries patching the WebUI for CORs. Go to the WebAPI.conf file and set CORS to false. The WebAPI will work again assuming you have the right python version of the egg.

metril avatar Jun 09 '20 06:06 metril

so i just ran through this myself, i just removed the WebAPI.conf and restarted deluge, which regenerated the WebAPI.conf and all seems well after restarteing deluge many times.

@Mycsina 's compiled egg

goldenpipes avatar Sep 23 '20 00:09 goldenpipes

Just spent a couple hours trying to get this working before noticing that all the plugins in Deluge were labeled 3.8!!! @Mycsina thanks so much for this fix here. Had it working in 5 mins

chansearrington avatar Dec 24 '20 23:12 chansearrington

Also having this problem in the binhex container, no amount of editing conf files seems to do the trick. I've tried the 3.8 file linked above as well

Edit: turns out the binhex deluge container is now up to python 3.9, I renamed the webapi to 3.9 and it loaded and appears to work, still won't connect with organizr, though that could be another issue I need to work out

Brandoskey avatar Mar 18 '21 19:03 Brandoskey

@Brandoskey Hey! FYI, I just got this up and running.

I have Deluge setup with Docker using a volume for the /config. I downloaded this egg and extracted it at Deluge's plugin config folder /config/plugins. I renamed to 3.9 as you mentioned.

In the WebUI I enabled the plugin, and in Organizr I was able to enable, save, and test the integration. It works as expected.

Let me know if you need help.

kinduff avatar Mar 28 '21 02:03 kinduff