posborne / putio-sync

Python daemon that automatically downloads files from put.io
MIT License
29 stars 12 forks source link

Fix #27 by tweaking Transmission RPC support #28

Closed wpearse closed 8 years ago

wpearse commented 8 years ago

This PR is geared towards Transmission RPC masquerading, as mentioned in #27.

I can't take credit for this: @cedbossneo (who for some weird reason I've been calling "@chauber") wrote this code. I simply went through his changes and cherry-picked the stuff that would fix the problem, and tidy up some other issues.

It fixes the following issues:

This PR changes the way that requests are handled, passing the entire RPC arguments hash through to the method handler. This, and the other tweaks above, seem to make Sonarr happy.

Before these changes, this command:

curl -H "Content-Type: application/json" -X POST -d '{"method":"torrent-get", "arguments":{"fields": ["id","hashString","name","downloadDir","status","totalSize","leftUntilDone","isFinished","eta","errorString"]}}' http://127.0.0.1:7001/transmission/rpc

Would return

{"error_description": "'Transfer' object has no attribute 'errorMessage'", "result": "error"}

Now, after these changes, we get:

{"result": "success", "arguments": {"torrents": [{"status": 3, "name": "...", "downloadDir": "/media/sf_put-io/download/", "totalSize": ..., "hashString": "...", "errorString": "", "isFinished": false, "eta": 0, "leftUntilDone": 0, "id": ...}, {"status": 4, "name": "...", "downloadDir": "/media/sf_put-io/download/", "totalSize": ..., "hashString": "...", "errorString": "", "isFinished": false, "eta": 0, "leftUntilDone": 188884863, "id": ...}]}}

(the ... are where I've removed irrelevant information).

wpearse commented 8 years ago

Oh yeah, I also tested it by adding it as Transmission Download Client in Sonarr, and running through a couple of downloads -- no problems.

posborne commented 8 years ago

Huh, I didn't even notice the fork. Wonder why no PR was issued against upstream? @wpearse are your changes at all different from those made by @cedbossneo? I would like to reuse those commits made by him -- any changes on top should be a separate commit. That helps with traceability and also ensures that the committer gets proper credit for the change.

If there are no differences, I can certainly pull the changes directly from the @cedbossneo remote.

wpearse commented 8 years ago

The only difference with my changes and @cedbossneo's remote at bc5e86457da47422cfe6409e179127fc077de3a3 are a Dockerfile.

More recent commits from his repo include some hard-coded stuff (e.g. hard-coded paths, and some post-download scripts).

I tried to open a PR from his bc5e...e3a3 commit to your master, but GitHub won't let me. I'm guessing either you or he will be able to, though.

wpearse commented 8 years ago

You can see the diff here: https://github.com/posborne/putio-sync/compare/master...cedbossneo:bc5e86457da47422cfe6409e179127fc077de3a3

cedbossneo commented 8 years ago

Hi,

I have no problem with that, i don't contribute to this fork anymore because i'm working on a new project to sync put.io in a different way.

Le ven. 25 mars 2016 à 05:33, Will Pearse notifications@github.com a écrit :

You can see the diff here: master...cedbossneo:bc5e86457da47422cfe6409e179127fc077de3a3 https://github.com/posborne/putio-sync/compare/master...cedbossneo:bc5e86457da47422cfe6409e179127fc077de3a3

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/posborne/putio-sync/pull/28#issuecomment-201131827

posborne commented 8 years ago

Ok, I'll wrangle together commits this weekend to get everything in tree properly and publish a new release.