-
-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Transmission support #637
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for homer-demo-content ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @jag-k. A transmission custom service will be nice!
I think we can simplify a bit the data fetching part, but other than than, it should be good.
if (this.proxy?.useCredentials) { | ||
options.credentials = "include"; | ||
} | ||
// Each item can override the credential settings | ||
if (this.item.useCredentials !== undefined) { | ||
options.credentials = | ||
this.item.useCredentials === true ? "include" : "omit"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A custom fetch function is available (you already included it using the service
mixin), which handle the credential option and more. Could you update your code to use it and avoid code duplication ? Thanks 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the existing custom fetch, we don't have access to the response in the event of a non Response.OK result. We would need access to the response in order to obtain the "X-Transmission-Session-Id" after we are sent a 409 status code.
I have hacked it trivially with, but I'm sure there is a better / more correct way.
In service.js
`fetch: function (path, init, json = true, forceResponse = false)`
...
...
if (!response.ok) {
if (!forceResponse)
throw new Error("Not 2xx response");
else
return response;
}
let url; | ||
if (this.item?.rpc) { | ||
url = this.item.rpc; | ||
} else { | ||
url = this.endpoint; | ||
if (url.endsWith("/")) { | ||
url = url.slice(0, -1); | ||
} | ||
if (url.endsWith("/web")) { | ||
url = url.slice(0, -4); | ||
url += "/rpc"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need another config key for /rpc
endpoint. the endpoint
config key is made for this. It's supposed to be the url where to fetch the data. You just have to write in the documentation that endpoint
should contain the rpc url.
} | ||
} | ||
const response = await fetch(url, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use this.fetch
here.
// If the session id is not set, we need to get it from the response | ||
if (response.status === 409 && !this.sessionId) { | ||
const body = await response.text(); | ||
const match = body.match(/X-Transmission-Session-Id: ([a-z0-9]+)/i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the X-Transmission-Session-Id exist in the response headers, it would be easier / cleaner to get it from the headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use response.headers.get('x-transmission-session-id')
to get the session-id
I'm testing this PR, but I'm stuck on enabling CORS. I have transmission RPC enabled (works with android remote apps), but I don't see a way to enable CORS natively in transmission. Are you putting it behind a proxy to enable this? |
I got CORS working on NGINX for this by following this and then modifying the
I need to do that to get my version 3.x transmission to work. But on my other transmission install that was already 4.x I didn't need CORS at all and I could communicate without a proxy. I ended up upgrading my 3.x install to 4.x Thank you for this PR. |
Used colors from transmission-remote android app.
Display torrent count like Arr activity notification
I added some changes to this as a PR into jag-k repo |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #634
Type of change
Checklist:
config.yml
file