0o120 / pyruTorrent

2 stars 2 forks source link

Script is unable to authorize on website. #2

Open YozenPL opened 1 year ago

YozenPL commented 1 year ago

Script is unable to authorize on website. Login, and password are correct. I believe this is related to digest auth on website.

Traceback (most recent call last):
  File "/home/pi/scripts/./fatcat.py", line 17, in <module>
    rt.start_all(view='default', ratio_group=None)
  File "/home/pi/.local/lib/python3.9/site-packages/pyruTorrent/pyruTorrent.py", line 780, in start_all
    response = self.client.system.multicall(methods)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
    response = self.__transport.request(
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in single_request
    raise ProtocolError(
xmlrpc.client.ProtocolError: <ProtocolError for ************/rutorrent/plugins/httprpc/action.php: 401 Unauthorized>
0o120 commented 1 year ago

When you initialize your instance, does it look similar to this?

rtorrent = rTorrent(host="address", port="port", username="login", password="password")

If you give me a sample of what you're using, I can get a better idea of what might be causing it.

YozenPL commented 1 year ago

I used the example: rt = rTorrent( host='my_address_here', port=443, username="my_login_here", password="my_pass_here", rpc_path='/rutorrent/plugins/httprpc/action.php' )

httprpc is working on the server as android app "Transdrone" can connect to it.

YozenPL commented 1 year ago

Ok I found this is the problem with xmlrpc.client as is doing "Basic auth" only.


server_url = "https://user:pass@address:443/rutorrent/plugins/httprpc/action.php"
server = xmlrpc.client.Server(server_url)

len(server.download_list("", "main"))

Gave me the same error - 401 Unauthorized.

0o120 commented 1 year ago

I used the example: rt = rTorrent( host='my_address_here', port=443, username="my_login_here", password="my_pass_here", rpc_path='/rutorrent/plugins/httprpc/action.php' )

httprpc is working on the server as android app "Transdrone" can connect to it.

Wondering if you have special characters in your username and pass that are not being encoded properly. Thus causing the auth error.

Can you try using:

import urllib.parse

username = urllib.parse.quote("username")
password = urllib.parse.quote("password")

On your username and password, then passing it into the rtorrent instance.

YozenPL commented 1 year ago

The only special character is "_" in login. Rest of the symbols are [a-z], [A-Z], [0-9]

0o120 commented 1 year ago

The only special character is "_" in login. Rest of the symbols are [a-z], [A-Z], [0-9]

Will look into it further later when I get to a PC. I'll check the Transdrone source and see why it's working over over pythons xmlrpc.

0o120 commented 1 year ago

@YozenPL

Can you give rpc_path="/RPC2" a shot and see if that works with rt.get_torrents()

The difference between Transdrone and this script is Transdrone uses the direct "/RPC2" host server while this script leeches off rutorrents httprpc plugin "/rutorrent/plugins/httprpc/action.php", avoiding "/RPC2" setup.

Do you happen to have access to your rutorrent UI interface? I'm wondering if that action.php directory access has a different user\pass from what your using, which is causing the 401 Unauthorized error. The only way I can replicate that error is using a bad password. Besides that, it works for me using "/rutorrent/plugins/httprpc/action.php".