diff --git a/README.md b/README.md
index 59a3e64..297b139 100644
--- a/README.md
+++ b/README.md
@@ -44,10 +44,8 @@ The _allow remote_ option is to allow remote add and stream of torrents.
## Todo
-* [x] Add RAR streaming support
* [ ] Better feedback in interface about streams
* [ ] Better feedback when using API
-* [x] Reverse proxy improvement (e.g. port different than bind port)
* [ ] Fix problems when removing torrent from Deluge (sea of errors)
# HTTP API Usage
@@ -102,6 +100,9 @@ List of URL GET Arguments
# Version Info
+## Version 0.10.5
+* Added support for serving files inline
+
## Version 0.10.4
* Trying to set max priority less as it destroys performance
diff --git a/setup.py b/setup.py
index 9094d69..7324856 100644
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@ from setuptools import setup, find_packages
__plugin_name__ = "Streaming"
__author__ = "Anders Jensen"
__author_email__ = "johndoee@tidalstream.org"
-__version__ = "0.10.4"
+__version__ = "0.10.5"
__url__ = "https://github.com/JohnDoee/deluge-streaming"
__license__ = "GPLv3"
__description__ = "Enables streaming of files while downloading them."
diff --git a/streaming/core.py b/streaming/core.py
index bfbb784..b965941 100644
--- a/streaming/core.py
+++ b/streaming/core.py
@@ -180,6 +180,7 @@ class Torrent(object):
best_reader_from_byte = max(reader[1] for reader in self.readers.values() if reader[1] <= from_byte)
best_reader_piece = best_reader_from_byte // self.piece_length
downloading_pieces = self.get_currently_downloading()
+ # TODO: unfinished_piece can be None
for unfinished_piece, status in enumerate(self.torrent.status.pieces[best_reader_piece:], best_reader_piece):
if not status and unfinished_piece not in downloading_pieces:
break
@@ -809,7 +810,7 @@ class Core(CorePluginBase):
@export
@defer.inlineCallbacks
- def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None, includes_name=False, wait_for_end_pieces=False, label=None):
+ def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None, includes_name=False, wait_for_end_pieces=False, label=None, as_inline=False):
logger.debug('Trying to stream infohash:%s, url:%s, filepath_or_index:%s' % (infohash, url, filepath_or_index))
torrent = get_torrent(infohash)
@@ -851,7 +852,7 @@ class Core(CorePluginBase):
try:
stream_or_item = yield defer.maybeDeferred(self.torrent_handler.stream, infohash, fn, wait_for_end_pieces=wait_for_end_pieces)
- stream_url = self.thomas_http_output.serve_item(stream_or_item)
+ stream_url = self.thomas_http_output.serve_item(stream_or_item, as_inline=as_inline)
except:
logger.exception('Failed to stream torrent')
defer.returnValue({'status': 'error', 'message': 'failed to stream torrent'})
diff --git a/streaming/data/streaming.js b/streaming/data/streaming.js
index 84d8430..a487525 100644
--- a/streaming/data/streaming.js
+++ b/streaming/data/streaming.js
@@ -349,20 +349,23 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
deluge.preferences.addPage(this.prefsPage);
console.log('Streaming plugin loaded');
- var doStream = function (tid, fileIndex) {
- deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, true, {
+ var doStream = function (tid, fileIndex, asInline) {
+ deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, true, false, null, asInline, {
success: function (result) {
- console.log('Got result', result);
if (result.status == 'success') {
- var url = result.url;
- if (result.use_stream_urls) {
- url = 'stream+' + url;
- if (result.auto_open_stream_urls) {
- window.location.assign(url);
- return;
+ if (asInline) {
+ window.open(result.url, '_blank');
+ } else {
+ var url = result.url;
+ if (result.use_stream_urls) {
+ url = 'stream+' + url;
+ if (result.auto_open_stream_urls) {
+ window.location.assign(url);
+ return;
+ }
}
+ Ext.Msg.alert('Stream ready', 'URL for stream: ' + url + '');
}
- Ext.Msg.alert('Stream ready', 'URL for stream: ' + url + '');
} else {
Ext.Msg.alert('Stream failed', 'Error message: ' + result.message);
}
@@ -370,6 +373,28 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
})
}
+ var triggerStreamFile = function (asInline) {
+ var files = deluge.details.items.items[2];
+ var nodes = files.getSelectionModel().getSelectedNodes();
+ if (nodes) {
+ var fileIndex = nodes[0].attributes.fileIndex;
+ var tid = files.torrentId;
+ if (fileIndex >= 0) {
+ doStream(tid, fileIndex, asInline);
+ }
+ }
+ }
+
+ deluge.menus.filePriorities.addMenuItem({
+ id: 'playthis',
+ text: 'Play in browser',
+ iconCls: 'icon-resume',
+ handler: function (item, event) {
+ deluge.menus.filePriorities.hide();
+ triggerStreamFile(true);
+ return false;
+ }
+ });
deluge.menus.filePriorities.addMenuItem({
id: 'streamthis',
@@ -377,15 +402,26 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
iconCls: 'icon-down',
handler: function (item, event) {
deluge.menus.filePriorities.hide();
- var files = deluge.details.items.items[2];
- var nodes = files.getSelectionModel().getSelectedNodes();
- if (nodes) {
- var fileIndex = nodes[0].attributes.fileIndex;
- var tid = files.torrentId;
- if (fileIndex >= 0) {
- doStream(tid, fileIndex);
- }
- }
+ triggerStreamFile(false);
+ return false;
+ }
+ });
+
+
+ var triggerStreamTorrent = function (asInline) {
+ var ids = deluge.torrents.getSelectedIds();
+ if (ids) {
+ doStream(ids[0], null, asInline);
+ }
+ }
+
+ deluge.menus.torrent.addMenuItem({
+ id: 'playthistorrent',
+ text: 'Play in browser',
+ iconCls: 'icon-resume',
+ handler: function (item, event) {
+ deluge.menus.torrent.hide();
+ triggerStreamTorrent(true);
return false;
}
});
@@ -396,10 +432,7 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
iconCls: 'icon-down',
handler: function (item, event) {
deluge.menus.torrent.hide();
- var ids = deluge.torrents.getSelectedIds();
- if (ids) {
- doStream(ids[0]);
- }
+ triggerStreamTorrent(false);
return false;
}
});