Feature #2374

Ability to get the torrent file with httpReq and then run it via torrent:browse or torrent:movie path

Added by Wain . over 6 years ago. Updated over 6 years ago.

Status:FixedStart date:11/15/2014
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

100%

Category:API
Target version:4.8

Description

In the latest Showtime, we're able to load torrents only by providing its URL, which is loaded internally. However, certain sites require to send additional data to get it, such as POST params, custom cookies, etc. The last thing I was able to do is receive .torrent file itself inside the plugin using normal showtime.httpReq API, but still there's no way to put it further inside Showtime.
So, I assume there's at least 2 ways to achieve this:

1. Use plugin.addHTTPAuth API to regexp the download link and change its headers (doesn't work for me (Issue 2371))
2. Use showtime.httpReq API to load .torrent file contents, then use some new API function to load it.

Associated revisions

Revision f591997a
Added by Andreas Smas over 6 years ago

Add support for 'data:' URI scheme

Fixes #2374

Change included in version 4.7.520

History

#1 Updated by Leonid Protasov over 6 years ago

  • Subject changed from Getting .torrent files should have same configuration options as other URLs to Ability to get the torrent file with httpReq and then run it via torrent:browse or torrent:movie path

#2 Updated by Leonid Protasov over 6 years ago

But interesting thing is - you can login via httpReq via POST and then - website will send you pages with direct links to torrents. So frankly to say I don't know how important is implementing this feature. Correct me if I'm wrong.

#3 Updated by Wain . over 6 years ago

Leonid Protasov wrote:

But interesting thing is - you can login via httpReq via POST and then - website will send you pages with direct links to torrents. So frankly to say I don't know how important is implementing this feature. Correct me if I'm wrong.

I wouldn't have asked for this feature if things were so simple :). Of course I am logged it before accessing torrent links. Thing is, rutracker.org has onclick listener on the download link which sets 1 additional cookie before the request. Without it, access to the torrent file is forbidden. Reason is you can't access torrents with direct URL's.

#4 Updated by Wain . over 6 years ago

Leonid Protasov wrote:

But interesting thing is - you can login via httpReq via POST and then - website will send you pages with direct links to torrents. So frankly to say I don't know how important is implementing this feature. Correct me if I'm wrong.

I wouldn't have asked for this feature if things were so simple :). Of course I am logged it before accessing torrent links. Thing is, rutracker.org has onclick listener on the download link which sets 1 additional cookie before the request. Without it, access to the torrent file is forbidden. Reason is you can't access torrents with direct URL's.
I assume it'll be pretty easy to implement, as all the app logic stays the same except one DOESN'T have to to make the request for torrent - it's already there!

#5 Updated by Andreas Smas over 6 years ago

Here's my suggestion .

Implement the 'data:' URI scheme in showtime, see http://en.wikipedia.org/wiki/Data_URI_scheme

Then you can download the .torrent using HttpReq(), base64 encode it and do something like

page.redirect('torrent:movie:' + 'data:application/x-bittorrent;base64,' + Duktape.encode(response.data, 'base64'));

I think that's the most flexible, although it will be a VERY long URI :-)

#6 Updated by Wain . over 6 years ago

Andreas Öman wrote:

Here's my suggestion .

Implement the 'data:' URI scheme in showtime, see http://en.wikipedia.org/wiki/Data_URI_scheme

Then you can download the .torrent using HttpReq(), base64 encode it and do something like

[...]

I think that's the most flexible, although it will be a VERY long URI :-)

This will be extremely versatile! Torrent files are not usually THAT big to worry about string length. I mean, if it's common to use base64 to encode images (which can be pretty heavy), why can't we do that to smaller files? It's just one thing I'm conscious about: what else can we use it for? Why have such a flexible solution when it's used to do perform only one specific task?

#7 Updated by Andreas Smas over 6 years ago

  • Status changed from New to Accepted
  • Target version set to 4.8

Wain . wrote:

Andreas Öman wrote:

Here's my suggestion .

Implement the 'data:' URI scheme in showtime, see http://en.wikipedia.org/wiki/Data_URI_scheme

Then you can download the .torrent using HttpReq(), base64 encode it and do something like

[...]

I think that's the most flexible, although it will be a VERY long URI :-)

This will be extremely versatile! Torrent files are not usually THAT big to worry about string length. I mean, if it's common to use base64 to encode images (which can be pretty heavy), why can't we do that to smaller files? It's just one thing I'm conscious about: what else can we use it for? Why have such a flexible solution when it's used to do perform only one specific task?

I think in fact that's it's not so much about being flexible/generic as that it doesn't need that many changes in Showtime.

  • The bittorrent system does not need to be modified at all
  • No new javascript functions needs to be added (Duktape already have base64 encoding)
  • page.redirect() is already in place
  • The only thing needed to be added is the data URI scheme which is just a single isolated file on its own.

#8 Updated by Wain . over 6 years ago

Andreas Öman wrote:

I think in fact that's it's not so much about being flexible/generic as that it doesn't need that many changes in Showtime.

  • The bittorrent system does not need to be modified at all
  • No new javascript functions needs to be added (Duktape already have base64 encoding)
  • page.redirect() is already in place
  • The only thing needed to be added is the data URI scheme which is just a single isolated file on its own.

Okay, I'm not as familiar with Showtime internals as you are.
Thanks for your support, will be looking forward for this feature being implemented in the next releases!

#9 Updated by Andreas Smas over 6 years ago

  • Status changed from Accepted to Fixed
  • % Done changed from 0 to 100

#10 Updated by Andreas Smas over 6 years ago

This is an example of how to use it:

var page = require('showtime/page');
var http = require('showtime/http');

var p = new page.Route('indirectloadtest:(.*)', function(page, tgt) {

  var x = http.request(tgt);
  print(Duktape.info(x.bytes));

  var str = Duktape.enc('base64', x.bytes);
  page.redirect('torrent:browse:data:application/x-bittorrent;base64,' + str);

});

Also available in: Atom PDF