Opened 9 years ago

Last modified 3 years ago

#2404 reopened Enhancement

Web Client should support HTML5's registerContentHandler

Reported by: Screwtape Owned by: kjg
Priority: Normal Milestone: None Set
Component: Web Client Version: 1.83
Severity: Normal Keywords: patch-needed
Cc:

Description

When the user clicks on a link to a filetype that Firefox can't handle itself, Firefox lets you choose whether to save the file to disk, or to open it in some application. The list of available applications for any given filetype comes from the user's OS, but websites can register themselves as being able to handle particular content-types using window.navigator.registerContentHandler (introduced with Firefox 3, and part of the HTML5 spec so it will likely be supported by Safari, Opera and Chrome sooner or later).

In my ideal world, I would be able to visit, say, the Preferences dialog of the Web Client, click a button to register the Web Client as a handler for torrent files, then every time I click a link to a torrent file anywhere on the Web, it would be automatically sent to my Transmission daemon.

Attachments (2)

register-handler-html5.patch (4.6 KB) - added by lembregtse 8 years ago.
register-handler-html5-new.patch (4.8 KB) - added by hiram 5 years ago.
New version of patch, based on trunk (rev 14017)

Download all attachments as: .zip

Change History (20)

comment:1 Changed 8 years ago by kjg

  • Keywords patch-needed added

comment:2 follow-up: Changed 8 years ago by lembregtse

I've started working on this because I like the feature request. I've completed this for magnet links (tested with firefox 3.7pre1)

window.navigator.registerProtocolHandler("magnet", "?addtorrent=%s", "Transmission");

And then a little javascript modification in transmission.remote.js and transmission.js completed the ?addtorrent= part (not sure if that is completely fool proof though)

But I'm stuck with the

window.navigator.registerContentHandler("application/x-bittorrent", "?addtorrent=%s", "Transmission");

part, it simply wont work, if anyone has any experience with this javascript call please let me know.

comment:3 in reply to: ↑ 2 Changed 8 years ago by lembregtse

Replying to lembregtse:

I've started working on this because I like the feature request. I've completed this for magnet links (tested with firefox 3.7pre1)

window.navigator.registerProtocolHandler("magnet", "?addtorrent=%s", "Transmission");

And then a little javascript modification in transmission.remote.js and transmission.js completed the ?addtorrent= part (not sure if that is completely fool proof though)

But I'm stuck with the

window.navigator.registerContentHandler("application/x-bittorrent", "?addtorrent=%s", "Transmission");

part, it simply wont work, if anyone has any experience with this javascript call please let me know.

https://developer.mozilla.org/en/Web-based_protocol_handlers

I got the feeling Firefox hasn't implemented content handlers other than for https://developer.mozilla.org/en/Adding_feed_readers_to_Firefox

Webkit almost has it though...

I'll complete this as soon as firefox / chrome have it completely implemented.

comment:4 Changed 8 years ago by Screwtape

The actual MDC docs say "For Firefox 2, only the application/vnd.mozilla.maybe.feed, application/atom+xml, and application/rss+xml MIME types are supported.", although apparently they mean "Firefox 2 and above", not "Firefox 2, but fixed in the intervening several years". The Firefox bug sadly hasn't seen much activity, andChrome's ticket is waiting on the underlying WebKit ticket, committed three months ago.

It might be worth adding support for the magnet URI scheme even without support for the torrent content handler; I don't know of any sites that offer magnet links, but I've heard of them before so such a feature would likely be useful to somebody.

comment:5 Changed 8 years ago by lembregtse

Piratebay recently introduced magnet links for all their torrents. I'll submit a patch later today for magnet support.

comment:6 Changed 8 years ago by lembregtse

  • Version changed from 1.73 to 1.83+

I've prepared the patch.

Functions:

  • add a ?addtorrent=torrent-location|magnet-location function in transmission.remote.js it parses the window.location.href for ?vars and look for the addtorrent var, if there is one it will forward the torrent to rpc using the already there function addTorrentByUrl using the _Prefs Autostart setting
  • add a button to the preference page in index.html to set Transmission Web as a web application in the browser for .torrent (application/x-bittorrent) and magnet: protocol. The latter already works in FF3+, support for both should be added in browsers in the future (browsers). But this patch should work for both
  • so when a user goes to for example thepiratebay.org and clicks on a magnet link he will be forwarded to: http(s):host:port/path_to_transmission_web/?addtorrent=%s where %s will be unescaped and send through rcp

Changed 8 years ago by lembregtse

comment:7 Changed 8 years ago by charles

  • Resolution set to duplicate
  • Status changed from new to closed

This ticket has been superceded by #3176, since Kettu already does this.

comment:8 Changed 6 years ago by hiram

  • Resolution duplicate deleted
  • Status changed from closed to reopened

This is still an issue since kettu has never seemed to replace the current webclient. I would really like to have this, since it saves me from reapplying the patch every time transmission is updated. The current patch still works, only the part where it retrieves the start-on-add preference doesn't.

comment:9 Changed 6 years ago by jordan

  • Version changed from 1.83+ to 1.83

comment:10 Changed 6 years ago by hiram

  • Version changed from 1.83 to 2.51

comment:11 Changed 6 years ago by livings124

  • Version changed from 2.51 to 1.83

comment:12 Changed 6 years ago by hiram

  • Version changed from 1.83 to 2.51

This is also relevant in more recent versions like 2.51 and probably newer (not checked)

It would be nice not to patch this every time Transmission gets updated.

comment:13 Changed 6 years ago by livings124

  • Version changed from 2.51 to 1.83

If it wasn't relevant to more recent versions this would be closed. Also, 2.51 is not the current version, so you should not be reporting bugs against it. By changing the version, we have no way to know where the problem originated.

Changed 5 years ago by hiram

New version of patch, based on trunk (rev 14017)

comment:14 Changed 5 years ago by hiram

I added a patch based on the previous patch. Does exactly the same as the previous patch. I changed a bit around the pref dialog since that part of the code has changed since last patch. This might need some review

comment:15 Changed 3 years ago by killemov

  • Resolution set to wontfix
  • Status changed from reopened to closed
  • Version 1.83 deleted

This will never work because ALL magnets and torrents have to be uploaded through the rpc. The direct upload link approach is deprecated.

comment:16 Changed 3 years ago by hiram

  • Version set to 2.84

Seriously? The patch already works as is for at least the trunk version it was based on.

Furthermore if you want the webinterface to be taken serious as a interface you at least should allow magnet links... Why should one have to go through all the trouble of copy pasting the link, opening the webinterface and using the upload button when this patch allows one to just click on the link... This works for the desktop client interface of every serious torrent client.

I can think of no good reason why this should not work for the webinterface, the whole idea is that the javascript part sees the url, sends it through the rpc like it would when you paste a magnet link in the upload box...

comment:17 Changed 3 years ago by mike.dld

  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Version changed from 2.84 to 1.83

@killemov: Deprecated by who and where? As far as I see RPC call is exactly what's being used here (checkForAddTorrentInUrl -> addTorrentByUrl -> 'torrent-add').

Last edited 3 years ago by mike.dld (previous) (diff)

comment:18 Changed 3 years ago by killemov

Ah, yes I stand corrected. Capturing magnets does work, capturing torrents doesn't yet. If I understand correctly a complete new copy of the web-UI will be opened. My suggestion would be to create a bare essentials page with code for uploading only.

@mike.dld: I was referring to "Upcoming breakage" after jordan copied the torrent upload solution from Shift.

Note: See TracTickets for help on using tickets.