mirror of
https://github.com/JohnDoee/deluge-streaming/
synced 2026-07-01 07:31:17 -07:00
Merge branch 'release/0.10.5'
This commit is contained in:
@@ -44,10 +44,8 @@ The _allow remote_ option is to allow remote add and stream of torrents.
|
|||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
* [x] Add RAR streaming support
|
|
||||||
* [ ] Better feedback in interface about streams
|
* [ ] Better feedback in interface about streams
|
||||||
* [ ] Better feedback when using API
|
* [ ] 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)
|
* [ ] Fix problems when removing torrent from Deluge (sea of errors)
|
||||||
|
|
||||||
# HTTP API Usage
|
# HTTP API Usage
|
||||||
@@ -102,6 +100,9 @@ List of URL GET Arguments
|
|||||||
|
|
||||||
# Version Info
|
# Version Info
|
||||||
|
|
||||||
|
## Version 0.10.5
|
||||||
|
* Added support for serving files inline
|
||||||
|
|
||||||
## Version 0.10.4
|
## Version 0.10.4
|
||||||
* Trying to set max priority less as it destroys performance
|
* Trying to set max priority less as it destroys performance
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -42,7 +42,7 @@ from setuptools import setup, find_packages
|
|||||||
__plugin_name__ = "Streaming"
|
__plugin_name__ = "Streaming"
|
||||||
__author__ = "Anders Jensen"
|
__author__ = "Anders Jensen"
|
||||||
__author_email__ = "johndoee@tidalstream.org"
|
__author_email__ = "johndoee@tidalstream.org"
|
||||||
__version__ = "0.10.4"
|
__version__ = "0.10.5"
|
||||||
__url__ = "https://github.com/JohnDoee/deluge-streaming"
|
__url__ = "https://github.com/JohnDoee/deluge-streaming"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
__description__ = "Enables streaming of files while downloading them."
|
__description__ = "Enables streaming of files while downloading them."
|
||||||
|
|||||||
@@ -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_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
|
best_reader_piece = best_reader_from_byte // self.piece_length
|
||||||
downloading_pieces = self.get_currently_downloading()
|
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):
|
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:
|
if not status and unfinished_piece not in downloading_pieces:
|
||||||
break
|
break
|
||||||
@@ -809,7 +810,7 @@ class Core(CorePluginBase):
|
|||||||
|
|
||||||
@export
|
@export
|
||||||
@defer.inlineCallbacks
|
@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))
|
logger.debug('Trying to stream infohash:%s, url:%s, filepath_or_index:%s' % (infohash, url, filepath_or_index))
|
||||||
torrent = get_torrent(infohash)
|
torrent = get_torrent(infohash)
|
||||||
|
|
||||||
@@ -851,7 +852,7 @@ class Core(CorePluginBase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
stream_or_item = yield defer.maybeDeferred(self.torrent_handler.stream, infohash, fn, wait_for_end_pieces=wait_for_end_pieces)
|
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:
|
except:
|
||||||
logger.exception('Failed to stream torrent')
|
logger.exception('Failed to stream torrent')
|
||||||
defer.returnValue({'status': 'error', 'message': 'failed to stream torrent'})
|
defer.returnValue({'status': 'error', 'message': 'failed to stream torrent'})
|
||||||
|
|||||||
@@ -349,20 +349,23 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
|
|||||||
deluge.preferences.addPage(this.prefsPage);
|
deluge.preferences.addPage(this.prefsPage);
|
||||||
|
|
||||||
console.log('Streaming plugin loaded');
|
console.log('Streaming plugin loaded');
|
||||||
var doStream = function (tid, fileIndex) {
|
var doStream = function (tid, fileIndex, asInline) {
|
||||||
deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, true, {
|
deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, true, false, null, asInline, {
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
console.log('Got result', result);
|
|
||||||
if (result.status == 'success') {
|
if (result.status == 'success') {
|
||||||
var url = result.url;
|
if (asInline) {
|
||||||
if (result.use_stream_urls) {
|
window.open(result.url, '_blank');
|
||||||
url = 'stream+' + url;
|
} else {
|
||||||
if (result.auto_open_stream_urls) {
|
var url = result.url;
|
||||||
window.location.assign(url);
|
if (result.use_stream_urls) {
|
||||||
return;
|
url = 'stream+' + url;
|
||||||
|
if (result.auto_open_stream_urls) {
|
||||||
|
window.location.assign(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Ext.Msg.alert('Stream ready', 'URL for stream: <a target="_blank" href="' + url + '">' + url + '</a>');
|
||||||
}
|
}
|
||||||
Ext.Msg.alert('Stream ready', 'URL for stream: <a target="_blank" href="' + url + '">' + url + '</a>');
|
|
||||||
} else {
|
} else {
|
||||||
Ext.Msg.alert('Stream failed', 'Error message: ' + result.message);
|
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({
|
deluge.menus.filePriorities.addMenuItem({
|
||||||
id: 'streamthis',
|
id: 'streamthis',
|
||||||
@@ -377,15 +402,26 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
|
|||||||
iconCls: 'icon-down',
|
iconCls: 'icon-down',
|
||||||
handler: function (item, event) {
|
handler: function (item, event) {
|
||||||
deluge.menus.filePriorities.hide();
|
deluge.menus.filePriorities.hide();
|
||||||
var files = deluge.details.items.items[2];
|
triggerStreamFile(false);
|
||||||
var nodes = files.getSelectionModel().getSelectedNodes();
|
return false;
|
||||||
if (nodes) {
|
}
|
||||||
var fileIndex = nodes[0].attributes.fileIndex;
|
});
|
||||||
var tid = files.torrentId;
|
|
||||||
if (fileIndex >= 0) {
|
|
||||||
doStream(tid, fileIndex);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -396,10 +432,7 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
|
|||||||
iconCls: 'icon-down',
|
iconCls: 'icon-down',
|
||||||
handler: function (item, event) {
|
handler: function (item, event) {
|
||||||
deluge.menus.torrent.hide();
|
deluge.menus.torrent.hide();
|
||||||
var ids = deluge.torrents.getSelectedIds();
|
triggerStreamTorrent(false);
|
||||||
if (ids) {
|
|
||||||
doStream(ids[0]);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user