It appears that the docs are in a very disreputable state and I've literally spent 3x as much time on this then the other APIs combined with little to show.
At this point I'm simply trying to make a connection to the API and remove a torrent. This is what my test script looks like:
Code: Select all
import requests
rootca_pem_cert = r'D:\ProgramData\ssl\intechral.ddns.net\RootCA.pem'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
r=requests.session()
payload='{"id": 1, "method": "auth.login", "params": ["mypassword"]}'
s = r.post("https://mediabase:8113/json", headers=headers, data=payload, verify=rootca_pem_cert)
print s.headers
print s.content
payload2='{"id": 2, "method": "core.remove_torrent", "params": ["cf6c4817edddb56e06d36637ff241b4cc4be0233", "False"]}'
s = r.post("https://mediabase:8113/json", headers=headers, data=payload2, verify=rootca_pem_cert)
print s.headers
print s.text
Code: Select all
D:\>"d:\Python27\python.exe" test.py
{'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Set-Cookie': '_session_id=05ae4d07b88e90c5374acd24750dfbbb2330; Expires=Sun, 10 Sep 2017 05:25:18 GMT; Path=/json', 'Server': 'TwistedWeb/
16.4.1', 'Date': 'Sun, 10 Sep 2017 04:25:18 GMT', 'Content-Type': 'application/x-json'}
{"id": 1, "result": true, "error": null}
{'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Set-Cookie': '_session_id=05ae4d07b88e90c5374acd24750dfbbb2330; Expires=Sun, 10 Sep 2017 05:25:18 GMT; Path=/json', 'Server': 'TwistedWeb/
16.4.1', 'Date': 'Sun, 10 Sep 2017 04:25:18 GMT', 'Content-Type': 'application/x-json'}
{"id": 2, "result": true, "error": null}
I have no idea what is wrong as the methods and commands, etc that I have in my script are really the result of trial and error looking at dozens of posts here and stack exchange, etc.
I can't believe that the correct behavior is just to hang, but I know my basic syntax is correct since the first run will remove the torrent if there.
assistance please?