-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Register protocol handler in WebUI for magnet links #10552
Conversation
@Chocobo1 Made the following changes:
|
I tried testing in IE11, but it seems that I am having some trouble getting IE11 to run properly on my system even before my changes. The torrent list doesn't seem to show up for me in IE11. I am seeing no erros in the console with these changes though. |
@Chocobo1 Updated based on your feedback. |
I realized that there is really no need to wait for onClose to remove the download param from the URL, so I made that change as well. The download param is now removed from the WebUI url immediately, just before the extracted torrent uri is passed to the download page. |
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.
The rest LGTM.
Also you need to squash all the commits into the first one before I can approve & merge.
113b26a
to
d493797
Compare
Combined lines and squashed commits. |
Thank you! |
Is it possible to have it not prompt for options and just start downloading and additionally close it's window. So you would click on a link and it would just start without further UI |
I'm sure it's possible, though I doubt that would be desired by everyone such that it should be the default behavior. Probably better as a feature request to add an option for automatically starting magnet links. Would be similar to the option that currently exists for watching a directory for torrent files and automatically adding those. |
I'm getting the error "Your browser does not support this feature" in Firefox. |
Hmm, I know this was tested as working in Firefox when it was implemented: Taking a look at the recent revision history for the It looks like browsers may have tightened security around this API recently, it looks like specifically requiring a secure context (HTTPS, valid SSL certificate). Depending on the changes they made the typeof check we currently have may not be sufficient to catch the error. @BeecherNetworks Did this error break any functionality, or was it just being logged to the JS/devtools console? Also do you happen to know whether this error was observed over HTTP or HTTPS? To avoid the error, it may now be necessary to add code to check for https before attempting to register a protocol handler. |
It was working in at least both Chrome and Firefox previously, later when I'm home I'll test both of those, with and without SSL to determine the current status. |
This is on HTTP. I'll put Nginx in front of it tomorrow with a cert to check. |
FYI #11229 (comment) |
Background
As far as I know, currently adding magnet links for download in the WebUI means copying and pasting the magnet link manually. This PR adds some code to register the WebUI as a handler for magnet links. I just looked and apparently an issue was opened for this at #945, but was never implemented. This seemed easy enough to do so I did it and am currently using it via the alternative WebUI feature.
Changes
client.js
to callnavigator.registerProtocolHandler
, allowing the WebUI to be registered as a handler for magnet links. As I have coded it, magnet links will open the WebUI and encode the magnet link into a query parameter named "magnet".MDN documentation for
navigator.registerProtocolHandler
: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandlerTo enable the WebUI to handle magnet links, the user must authorize it manually. In Google Chrome, this can be done by clicking on the "handler" icon in the browser's address bar.
After doing this, when the user clicks on a magnet link in the browser, the WebUI will be opened and the "add torrrent link" dialog will be automatically opened with the magnet link already added.
Screenshot