mirror of
https://github.com/JohnDoee/deluge-streaming/
synced 2026-07-01 07:31:17 -07:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5228870bec | ||
|
|
a5d44a536a | ||
|
|
28aa99750a | ||
|
|
8e97331c2c | ||
|
|
67ff10b144 | ||
|
|
21fd98dfea | ||
|
|
1cf05ed46c | ||
|
|
49c4733a1e | ||
|
|
a29a69ba11 | ||
|
|
0bd7b8d40d | ||
|
|
6b2817ce5e | ||
|
|
0cc8ed4280 | ||
|
|
636bd0edc2 | ||
|
|
6bc72dbc44 | ||
|
|
c85c5763d6 | ||
|
|
bcc2067e55 | ||
|
|
1d31efa48c | ||
|
|
5859a19e0e |
23
README.md
23
README.md
@@ -1,7 +1,7 @@
|
||||
# Streaming Plugin
|
||||
https://github.com/JohnDoee/deluge-streaming
|
||||
|
||||
(c)2015 by Anders Jensen <johndoee@tidalstream.org>
|
||||
(c)2016 by Anders Jensen <johndoee@tidalstream.org>
|
||||
|
||||
## Description
|
||||
|
||||
@@ -23,7 +23,6 @@ Under that tab, eggs for Python 2.6 and 2.7 should exist.
|
||||
* Select _files_ tab
|
||||
* Right-click a file.
|
||||
* Click _Stream this file_
|
||||
* **WAIT**, it will try to buffer the first pieces of the file before generating a link (no feedback yet).
|
||||
* Select the link, open it in a media player, e.g. VLC or MPC
|
||||
|
||||
If you want to stream from a non-local computer, e.g. your seedbox, you will need to change the IP in option to the external server ip.
|
||||
@@ -35,12 +34,24 @@ make Deluge an abstraction layer for the [TidalStream](http://www.tidalstream.or
|
||||
|
||||
The _allow remote_ option is to allow remote add and stream of torrents.
|
||||
|
||||
## ToDo
|
||||
|
||||
* Add feedback when preparing stream.
|
||||
|
||||
# Version Info
|
||||
|
||||
## Version 0.7.1
|
||||
* Trying to fix bug where piece buffer went empty
|
||||
* Added support for SSL.
|
||||
|
||||
## Version 0.7.0
|
||||
* Shrinked code by redoing queue algorithm. This should prevent more stalled downloads and allow it to act bittorrenty if necessary.
|
||||
* Added support for waiting for end pieces to satisfy some video players (KODI)
|
||||
|
||||
## Version 0.6.1
|
||||
* Should not have been in changelog: Fixed "resume on complete" broken-ness (i hope)
|
||||
|
||||
## Version 0.6.0
|
||||
* Fixed URL encoding error
|
||||
* Fixed "resume on complete" broken-ness (i hope)
|
||||
* Changed default to not use stream urls
|
||||
|
||||
## Version 0.5.0
|
||||
* Restructured the whole plugin
|
||||
* Added support for StreamProtocol
|
||||
|
||||
3
setup.py
3
setup.py
@@ -42,7 +42,7 @@ from setuptools import setup
|
||||
__plugin_name__ = "Streaming"
|
||||
__author__ = "John Doee"
|
||||
__author_email__ = "johndoee@tidalstream.org"
|
||||
__version__ = "0.5.0"
|
||||
__version__ = "0.7.1"
|
||||
__url__ = "https://github.com/JohnDoee/deluge-streaming"
|
||||
__license__ = "GPLv3"
|
||||
__description__ = "Enables streaming of files while downloading them."
|
||||
@@ -59,7 +59,6 @@ downloads ahead, this enables seeking in video files.
|
||||
* Select _files_ tab
|
||||
* Right-click a file.
|
||||
* Click _Stream this file_
|
||||
* **WAIT**, it will try to buffer the first pieces of the file before generating a link (no feedback yet).
|
||||
* Select the link, open it in a media player, e.g. VLC or MPC
|
||||
|
||||
If you want to stream from a non-local computer, e.g. your seedbox, you will need to change the IP in option to the external server ip."""
|
||||
|
||||
@@ -46,10 +46,11 @@ import urllib
|
||||
import deluge.configmanager
|
||||
|
||||
from collections import defaultdict
|
||||
from copy import copy
|
||||
|
||||
from deluge import component
|
||||
from deluge import component, configmanager
|
||||
from deluge._libtorrent import lt
|
||||
from deluge.core.rpcserver import export
|
||||
from deluge.core.rpcserver import export, check_ssl_keys
|
||||
from deluge.plugins.pluginbase import CorePluginBase
|
||||
|
||||
from twisted.internet import reactor, defer, task
|
||||
@@ -65,19 +66,43 @@ DEFAULT_PREFS = {
|
||||
'ip': '127.0.0.1',
|
||||
'port': 46123,
|
||||
'allow_remote': False,
|
||||
'reset_complete': True,
|
||||
'use_stream_urls': True,
|
||||
'download_only_streamed': False,
|
||||
'use_stream_urls': False,
|
||||
'auto_open_stream_urls': False,
|
||||
'use_ssl': False,
|
||||
'remote_username': 'username',
|
||||
'remote_password': 'password',
|
||||
'serve_method': 'standalone',
|
||||
'ssl_source': 'daemon',
|
||||
'ssl_priv_key_path': '',
|
||||
'ssl_cert_path': '',
|
||||
}
|
||||
|
||||
PRIORITY_INCREASE = 5
|
||||
|
||||
def sleep(seconds):
|
||||
d = defer.Deferred()
|
||||
reactor.callLater(seconds, d.callback, seconds)
|
||||
return d
|
||||
|
||||
class ServerContextFactory(object):
|
||||
def __init__(self, cert_file, key_file):
|
||||
self._cert_file = cert_file
|
||||
self._key_file = key_file
|
||||
|
||||
def getContext(self):
|
||||
from OpenSSL import SSL
|
||||
|
||||
method = getattr(SSL, 'TLSv1_1_METHOD', None)
|
||||
if method is None:
|
||||
method = getattr(SSL, 'SSLv23_METHOD', None)
|
||||
|
||||
ctx = SSL.Context(method)
|
||||
ctx.use_certificate_file(self._cert_file)
|
||||
ctx.use_certificate_chain_file(self._cert_file)
|
||||
ctx.use_privatekey_file(self._key_file)
|
||||
return ctx
|
||||
|
||||
class FileServeResource(resource.Resource):
|
||||
isLeaf = True
|
||||
|
||||
@@ -95,7 +120,7 @@ class FileServeResource(resource.Resource):
|
||||
return token
|
||||
|
||||
def render_GET(self, request):
|
||||
key = request.path.split('/')[2]
|
||||
key = request.postpath[0]
|
||||
if key not in self.file_mapping:
|
||||
return resource.NoResource().render(request)
|
||||
|
||||
@@ -182,6 +207,7 @@ class TorrentFile(object): # can be read from, knows about itself
|
||||
self.index = index
|
||||
|
||||
self.file_requested = False
|
||||
self.file_requested_once = False
|
||||
self.do_shutdown = False
|
||||
self.first_piece_end = self.piece_size * (self.first_piece + 1) - offset
|
||||
self.waiting_pieces = {}
|
||||
@@ -198,14 +224,15 @@ class TorrentFile(object): # can be read from, knows about itself
|
||||
if not self.registered_alert:
|
||||
self.alerts.register_handler("read_piece_alert", self.on_alert_got_piece_data)
|
||||
self.registered_alert = True
|
||||
|
||||
tfr = TorrentFileReader(self)
|
||||
self.current_readers.append(tfr)
|
||||
self.file_requested = False
|
||||
|
||||
return tfr
|
||||
|
||||
def close(self, tfr):
|
||||
self.current_readers.remove(tfr)
|
||||
self.torrent.unprioritize_pieces(tfr)
|
||||
|
||||
def is_complete(self):
|
||||
torrent_status = self.torrent.torrent.get_status(['file_progress', 'state'])
|
||||
@@ -224,9 +251,25 @@ class TorrentFile(object): # can be read from, knows about itself
|
||||
if alert.piece not in self.waiting_pieces:
|
||||
logger.debug('Got data for piece %i, but no data needed for this piece?' % alert.piece)
|
||||
return
|
||||
# TODO: check piece size is not zero
|
||||
|
||||
self.waiting_pieces[alert.piece].callback(alert.buffer)
|
||||
if alert.buffer is None:
|
||||
return
|
||||
|
||||
piece_data = copy(alert.buffer)
|
||||
self.waiting_pieces[alert.piece].callback(piece_data)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def wait_for_end_pieces(self):
|
||||
handle = self.torrent.torrent.handle
|
||||
for piece in [self.first_piece, self.last_piece]:
|
||||
handle.set_piece_deadline(piece, 0)
|
||||
handle.piece_priority(piece, 7)
|
||||
|
||||
while not handle.have_piece(self.first_piece) and not handle.have_piece(self.last_piece):
|
||||
if self.do_shutdown:
|
||||
raise Exception('Shutting down')
|
||||
logger.debug('Did not have piece %i, waiting' % piece)
|
||||
yield sleep(1)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_piece_data(self, piece):
|
||||
@@ -239,12 +282,10 @@ class TorrentFile(object): # can be read from, knows about itself
|
||||
self.waiting_pieces[piece] = defer.Deferred()
|
||||
|
||||
logger.debug('Waiting for %s' % piece)
|
||||
self.torrent.schedule_piece(self, piece, 0)
|
||||
while not self.torrent.torrent.handle.have_piece(piece):
|
||||
if self.do_shutdown:
|
||||
raise Exception()
|
||||
raise Exception('Shutting down')
|
||||
logger.debug('Did not have piece %i, waiting' % piece)
|
||||
self.torrent.unrelease()
|
||||
yield sleep(1)
|
||||
|
||||
self.torrent.torrent.handle.read_piece(piece)
|
||||
@@ -256,7 +297,6 @@ class TorrentFile(object): # can be read from, knows about itself
|
||||
defer.returnValue(data)
|
||||
|
||||
def shutdown(self):
|
||||
#self.alerts.deregister_handler(self.on_alert_torrent_finished)
|
||||
self.do_shutdown = True
|
||||
|
||||
class Torrent(object):
|
||||
@@ -271,7 +311,7 @@ class Torrent(object):
|
||||
self.torrent_files = None
|
||||
self.priority_increased = defaultdict(set)
|
||||
self.do_shutdown = False
|
||||
self.torrent_released = False # set to True if all the files are set to download
|
||||
self.torrent_released = True # set to True if all the files are set to download
|
||||
|
||||
|
||||
self.populate_files()
|
||||
@@ -279,8 +319,8 @@ class Torrent(object):
|
||||
|
||||
self.last_piece = self.torrent_files[-1].last_piece
|
||||
self.torrent.handle.set_sequential_download(True)
|
||||
self.torrent.handle.set_priority(1)
|
||||
reactor.callLater(0, self.update_piece_priority)
|
||||
reactor.callLater(0, self.blackhole_all_pieces, 0, self.last_piece)
|
||||
|
||||
def populate_files(self):
|
||||
self.torrent_files = []
|
||||
@@ -295,23 +335,23 @@ class Torrent(object):
|
||||
last_piece = (f['offset'] + f['size']) / piece_length
|
||||
full_path = os.path.join(save_path, f['path'])
|
||||
|
||||
path = f['path']
|
||||
if '/' in path:
|
||||
path = '/'.join(path.split('/')[1:])
|
||||
|
||||
self.torrent_files.append(TorrentFile(self, first_piece, last_piece, piece_length, f['offset'],
|
||||
path, full_path, f['size'], f['index']))
|
||||
f['path'], full_path, f['size'], f['index']))
|
||||
|
||||
return files
|
||||
|
||||
def find_file(self, file_or_index=None):
|
||||
def find_file(self, file_or_index=None, includes_name=False):
|
||||
best_file = None
|
||||
biggest_file_size = 0
|
||||
|
||||
for i, f in enumerate(self.torrent_files):
|
||||
logger.debug('Testing file %r against %s / %r' % (file_or_index, i, f.path))
|
||||
path = f.path
|
||||
if not includes_name and '/' in path:
|
||||
path = '/'.join(path.split('/')[1:])
|
||||
|
||||
logger.debug('Testing file %r against %s / %r' % (file_or_index, i, path))
|
||||
if file_or_index is not None:
|
||||
if i == file_or_index or f.path == file_or_index:
|
||||
if i == file_or_index or path == file_or_index:
|
||||
best_file = f
|
||||
break
|
||||
else:
|
||||
@@ -321,24 +361,13 @@ class Torrent(object):
|
||||
|
||||
return best_file
|
||||
|
||||
def get_file(self, file_or_index=None):
|
||||
f = self.find_file(file_or_index)
|
||||
def get_file(self, file_or_index=None, includes_name=False):
|
||||
f = self.find_file(file_or_index, includes_name)
|
||||
if f is None:
|
||||
raise UnknownFileException('Was unable to find %s' % file_or_index)
|
||||
|
||||
return f
|
||||
|
||||
def unprioritize_pieces(self, tfr):
|
||||
logger.debug('Unprioritizing pieces for %s' % tfr)
|
||||
currently_downloading = self.get_currently_downloading()
|
||||
|
||||
for piece, increased_by in self.priority_increased.items():
|
||||
if tfr in increased_by:
|
||||
increased_by.remove(tfr)
|
||||
if not increased_by and piece not in currently_downloading and not self.torrent.status.pieces[piece]:
|
||||
logger.debug('Unprioritizing piece %s' % piece)
|
||||
self.torrent.handle.piece_priority(piece, 0)
|
||||
|
||||
def get_currently_downloading(self):
|
||||
currently_downloading = set()
|
||||
for peer in self.torrent.handle.get_peer_info():
|
||||
@@ -347,27 +376,10 @@ class Torrent(object):
|
||||
|
||||
return currently_downloading
|
||||
|
||||
def blackhole_all_pieces(self, first_piece, last_piece):
|
||||
currently_downloading = self.get_currently_downloading()
|
||||
|
||||
logger.debug('Blacklisting pieces from %i to %i skipping %r' % (first_piece, last_piece, currently_downloading))
|
||||
for piece in range(first_piece, last_piece+1):
|
||||
if piece not in currently_downloading and not self.torrent.status.pieces[piece]:
|
||||
if piece in self.priority_increased:
|
||||
continue
|
||||
logger.debug('Setting piece priority %s to blacklist' % piece)
|
||||
self.torrent.handle.piece_priority(piece, 0)
|
||||
|
||||
def unrelease(self):
|
||||
if self.torrent_released:
|
||||
logger.debug('Unreleasing %s' % self.infohash)
|
||||
self.torrent_released = False
|
||||
self.torrent.set_file_priorities(self.file_priorities)
|
||||
self.blackhole_all_pieces(0, self.last_piece)
|
||||
|
||||
def get_torrent_file(self, file_or_index):
|
||||
f = self.get_file(file_or_index)
|
||||
def get_torrent_file(self, file_or_index, includes_name):
|
||||
f = self.get_file(file_or_index, includes_name)
|
||||
f.file_requested = True
|
||||
f.file_requested_once = True
|
||||
|
||||
self.torrent.resume()
|
||||
|
||||
@@ -380,117 +392,124 @@ class Torrent(object):
|
||||
should_update_priorities = True
|
||||
|
||||
if should_update_priorities and not f.is_complete(): # Need to do this stuff on seek too
|
||||
self.unrelease()
|
||||
self.torrent.set_file_priorities(self.file_priorities)
|
||||
|
||||
return f
|
||||
|
||||
def shutdown(self):
|
||||
logger.info('Shutting down torrent %s' % self.infohash)
|
||||
logger.info('Shutting down torrent %s' % (self.infohash, ))
|
||||
|
||||
self.torrent.handle.set_priority(0)
|
||||
|
||||
for piece, status in enumerate(self.torrent.status.pieces[0:self.last_piece+1]):
|
||||
if status:
|
||||
continue
|
||||
|
||||
priority = self.torrent.handle.piece_priority(piece)
|
||||
if priority == 0:
|
||||
self.torrent.handle.piece_priority(piece, 1)
|
||||
|
||||
if not self.torrent_handler.config['download_only_streamed']:
|
||||
logger.debug('Resetting file priorities')
|
||||
file_priorities = [(1 if fp == 0 else fp) for fp in self.file_priorities]
|
||||
self.torrent.set_file_priorities(file_priorities)
|
||||
|
||||
self.do_shutdown = True
|
||||
self.torrent_handler.remove_torrent(self.infohash)
|
||||
|
||||
for tf in self.torrent_files:
|
||||
tf.shutdown()
|
||||
|
||||
def schedule_piece(self, torrent_file, piece, distance):
|
||||
if torrent_file not in self.priority_increased[piece]:
|
||||
if not self.priority_increased[piece]:
|
||||
self.priority_increased[piece].add(torrent_file)
|
||||
|
||||
logger.debug('Scheduled piece %s at distance %s' % (piece, distance))
|
||||
|
||||
self.torrent.handle.piece_priority(piece, (7 if distance <= 4 else 6))
|
||||
self.torrent.handle.set_piece_deadline(piece, 700*(distance+1))
|
||||
|
||||
self.priority_increased[piece].add(torrent_file)
|
||||
|
||||
def do_pieces_schedule(self, torrent_file, currently_downloading, from_piece):
|
||||
logger.debug('Looking for stuff to do with pieces for file %s from piece %s' % (torrent_file, from_piece))
|
||||
|
||||
priority_increased = 0
|
||||
chain_size = 0
|
||||
download_chain_size = 0
|
||||
end_of_chain = False
|
||||
|
||||
current_buffer_offset = 5
|
||||
if self.torrent.status.pieces[torrent_file.last_piece]:
|
||||
if torrent_file.first_piece != torrent_file.last_piece and self.torrent.status.pieces[torrent_file.last_piece-1] \
|
||||
or torrent_file.first_piece == torrent_file.last_piece:
|
||||
current_buffer_offset = 20
|
||||
|
||||
for piece, status in enumerate(self.torrent.status.pieces[from_piece:torrent_file.last_piece+1], from_piece):
|
||||
if not end_of_chain:
|
||||
if status:
|
||||
chain_size += 1
|
||||
elif piece in currently_downloading:
|
||||
download_chain_size += 1
|
||||
|
||||
if not status and piece not in currently_downloading:
|
||||
if not end_of_chain:
|
||||
status_increase = max(11, chain_size-current_buffer_offset)
|
||||
end_of_chain = True
|
||||
|
||||
priority_increased += 1
|
||||
if priority_increased >= status_increase:
|
||||
logger.debug('Done increasing priority for %i pieces' % status_increase)
|
||||
break
|
||||
|
||||
self.schedule_piece(torrent_file, piece, piece-from_piece)
|
||||
else:
|
||||
logger.info('We are done with the rest of this chain, we might be able to increase others')
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def update_piece_priority(self): # if all do_pieces_schedule returns true, allow all pices of file to be downloaded or whole torernt
|
||||
def update_piece_priority(self): # if file streamed has reached end, unblacklist all prior pieces
|
||||
if self.do_shutdown:
|
||||
return
|
||||
|
||||
logger.debug('Updating piece priority for %s' % self.infohash)
|
||||
logger.debug('Updating piece priority for %s' % (self.infohash, ))
|
||||
currently_downloading = self.get_currently_downloading()
|
||||
|
||||
currently_downloading = set()
|
||||
for peer in self.torrent.handle.get_peer_info():
|
||||
if peer.downloading_piece_index != -1:
|
||||
currently_downloading.add(peer.downloading_piece_index)
|
||||
|
||||
all_heads_done = True
|
||||
for f in self.torrent_files:
|
||||
if not f.file_requested and not f.current_readers:
|
||||
if not f.file_requested and not f.current_readers: # nobody wants the file and nobody is watching
|
||||
continue
|
||||
|
||||
logger.debug('Rescheduling file %s' % f.path)
|
||||
logger.debug('Rescheduling file %s' % (f.path, ))
|
||||
|
||||
if f.file_requested:
|
||||
all_heads_done &= self.do_pieces_schedule(f, currently_downloading, f.first_piece)
|
||||
self.schedule_piece(f, f.last_piece, 0)
|
||||
if f.first_piece != f.last_piece:
|
||||
self.schedule_piece(f, f.last_piece-1, 1)
|
||||
heads = set()
|
||||
if f.file_requested: # we expect a piece head to be at start
|
||||
heads.add(f.first_piece)
|
||||
|
||||
waiting_for_pieces = set()
|
||||
|
||||
for tfr in f.current_readers:
|
||||
if tfr.waiting_for_piece is not None:
|
||||
logger.debug('Scheduling based on waiting for piece %s' % tfr.waiting_for_piece)
|
||||
all_heads_done &= self.do_pieces_schedule(f, currently_downloading, tfr.waiting_for_piece)
|
||||
elif tfr.current_piece is not None:
|
||||
logger.debug('Scheduling based on current piece %s' % tfr.current_piece)
|
||||
all_heads_done &= self.do_pieces_schedule(f, currently_downloading, tfr.current_piece)
|
||||
|
||||
if all(self.torrent.status.pieces):
|
||||
logger.debug('All pieces complete, no need to loop')
|
||||
return
|
||||
|
||||
if all_heads_done and not self.torrent_released:
|
||||
logger.debug('We are already done with all heads, figuring out what to do next')
|
||||
waiting_for_pieces.add(tfr.waiting_for_piece)
|
||||
|
||||
piece = max(tfr.waiting_for_piece, tfr.current_piece)
|
||||
if piece is not None:
|
||||
heads.add(piece)
|
||||
|
||||
if self.torrent_handler.config['reset_complete']:
|
||||
self.torrent_released = True
|
||||
logger.debug('Resetting all disabled files')
|
||||
file_priorities = [(1 if fp == 0 else fp) for fp in self.file_priorities]
|
||||
self.torrent.set_file_priorities(file_priorities)
|
||||
if not heads:
|
||||
continue
|
||||
|
||||
first_head = min(heads)
|
||||
|
||||
for head_piece in heads:
|
||||
priority_increased = 0
|
||||
for piece, status in enumerate(self.torrent.status.pieces[head_piece:f.last_piece+1], head_piece):
|
||||
#logger.debug('Checking status for %s/%s/%s/%s' % (head_piece, piece, status, self.torrent.handle.piece_priority(piece)))
|
||||
if status or piece in currently_downloading:
|
||||
continue
|
||||
|
||||
priority = self.torrent.handle.piece_priority(piece)
|
||||
if priority_increased < PRIORITY_INCREASE:
|
||||
priority_increased += 1
|
||||
|
||||
if piece in waiting_for_pieces:
|
||||
if priority < 7:
|
||||
logger.debug('setting priority for %s to 7 with deadline 0' % (piece, ))
|
||||
|
||||
self.torrent.handle.set_piece_deadline(piece, 0)
|
||||
self.torrent.handle.piece_priority(piece, 7)
|
||||
elif priority < 6:
|
||||
deadline = 3000 * priority_increased
|
||||
logger.debug('setting priority for %s to 6 with deadline %s' % (piece, deadline, ))
|
||||
self.torrent.handle.piece_priority(piece, 6)
|
||||
self.torrent.handle.set_piece_deadline(piece, deadline)
|
||||
|
||||
elif priority == 0:
|
||||
self.torrent.handle.piece_priority(piece, 1)
|
||||
|
||||
if head_piece == first_head:
|
||||
if priority_increased < PRIORITY_INCREASE:
|
||||
logger.debug('Everything we need has been scheduled, looking for pieces across file to unblacklist')
|
||||
for piece, status in enumerate(self.torrent.status.pieces[f.first_piece:f.last_piece+1], f.first_piece):
|
||||
if status:
|
||||
continue
|
||||
|
||||
priority = self.torrent.handle.piece_priority(piece)
|
||||
if priority == 0:
|
||||
self.torrent.handle.piece_priority(piece, 1)
|
||||
else:
|
||||
logger.debug('Looking for pieces before smallest head %s to blacklist' % (first_head, ))
|
||||
for piece, status in enumerate(self.torrent.status.pieces[f.first_piece:first_head], f.first_piece):
|
||||
if status or piece in currently_downloading:
|
||||
continue
|
||||
|
||||
if self.torrent.handle.piece_priority(piece) != 0:
|
||||
logger.debug('Blacklisting %i' % (piece, ))
|
||||
self.torrent.handle.piece_priority(piece, 0)
|
||||
|
||||
if not all_heads_done and self.torrent_released:
|
||||
logger.debug('Seems like the torrent was released too early')
|
||||
self.unrelease()
|
||||
found_requested = False
|
||||
for f in self.torrent_files:
|
||||
if f.file_requested_once:
|
||||
found_requested = True
|
||||
if not f.is_complete() or f.current_readers:
|
||||
break
|
||||
else:
|
||||
if found_requested:
|
||||
logger.debug('Nobody is currently using %s, shutting down torrent-handler' % (self.infohash, ))
|
||||
self.shutdown()
|
||||
|
||||
reactor.callLater(0.3, self.update_piece_priority)
|
||||
reactor.callLater(1, self.update_piece_priority)
|
||||
|
||||
class TorrentHandler(object):
|
||||
def __init__(self, config):
|
||||
@@ -500,12 +519,12 @@ class TorrentHandler(object):
|
||||
self.alerts = component.get("AlertManager")
|
||||
self.alerts.register_handler("torrent_removed_alert", self.on_alert_torrent_removed)
|
||||
|
||||
def get_stream(self, infohash, file_or_index=None):
|
||||
logger.info('Trying to stream infohash %s and file %s' % (infohash, file_or_index))
|
||||
def get_stream(self, infohash, file_or_index=None, includes_name=False):
|
||||
logger.info('Trying to stream infohash %s and file %s include_name %s' % (infohash, file_or_index, includes_name))
|
||||
if infohash not in self.torrents:
|
||||
self.torrents[infohash] = Torrent(self, infohash)
|
||||
|
||||
return self.torrents[infohash].get_torrent_file(file_or_index)
|
||||
return self.torrents[infohash].get_torrent_file(file_or_index, includes_name)
|
||||
|
||||
def on_alert_torrent_removed(self, alert):
|
||||
try:
|
||||
@@ -518,6 +537,9 @@ class TorrentHandler(object):
|
||||
return
|
||||
|
||||
self.torrents[torrent_id].shutdown()
|
||||
self.remove_torrent(torrent_id)
|
||||
|
||||
def remove_torrent(self, torrent_id):
|
||||
del self.torrents[torrent_id]
|
||||
|
||||
def shutdown(self):
|
||||
@@ -527,18 +549,11 @@ class TorrentHandler(object):
|
||||
torrent.shutdown()
|
||||
|
||||
class Core(CorePluginBase):
|
||||
listening = None
|
||||
base_url = None
|
||||
|
||||
def enable(self):
|
||||
self.config = deluge.configmanager.ConfigManager("streaming.conf", DEFAULT_PREFS)
|
||||
self.fsr = FileServeResource()
|
||||
|
||||
self.resource = Resource()
|
||||
self.resource.putChild('file', self.fsr)
|
||||
if self.config['allow_remote']:
|
||||
self.resource.putChild('stream', StreamResource(username=self.config['remote_username'],
|
||||
password=self.config['remote_password'],
|
||||
client=self))
|
||||
|
||||
self.site = server.Site(self.resource)
|
||||
|
||||
try:
|
||||
session = component.get("Core").session
|
||||
@@ -548,32 +563,122 @@ class Core(CorePluginBase):
|
||||
except AttributeError:
|
||||
logger.warning('Unable to exclude partial pieces')
|
||||
|
||||
self.fsr = FileServeResource()
|
||||
resource = Resource()
|
||||
resource.putChild('file', self.fsr)
|
||||
if self.config['allow_remote']:
|
||||
resource.putChild('stream', StreamResource(username=self.config['remote_username'],
|
||||
password=self.config['remote_password'],
|
||||
client=self))
|
||||
|
||||
base_resource = Resource()
|
||||
base_resource.putChild('streaming', resource)
|
||||
self.site = server.Site(base_resource)
|
||||
|
||||
self.torrent_handler = TorrentHandler(self.config)
|
||||
|
||||
try:
|
||||
self.listening = reactor.listenTCP(self.config['port'], self.site, interface=self.config['ip'])
|
||||
except:
|
||||
self.listening = reactor.listenTCP(self.config['port'], self.site, interface='127.0.0.1')
|
||||
plugin_manager = component.get("CorePluginManager")
|
||||
logger.warning('plugins %s' % (plugin_manager.get_enabled_plugins(), ))
|
||||
|
||||
self.base_url = 'http'
|
||||
if self.config['serve_method'] == 'standalone':
|
||||
if self.config['use_ssl'] and self.check_ssl(): # use default deluge (or webui), input custom
|
||||
if self.config['ssl_source'] == 'daemon':
|
||||
web_config = configmanager.ConfigManager("web.conf", {"pkey": "ssl/daemon.pkey",
|
||||
"cert": "ssl/daemon.cert"})
|
||||
|
||||
context = ServerContextFactory(configmanager.get_config_dir(web_config['cert']),
|
||||
configmanager.get_config_dir(web_config['pkey']))
|
||||
elif self.config['ssl_source'] == 'custom':
|
||||
context = ServerContextFactory(self.config['ssl_cert_path'],
|
||||
self.config['ssl_priv_key_path'])
|
||||
|
||||
try:
|
||||
self.listening = reactor.listenSSL(self.config['port'], self.site, context, interface=self.config['ip'])
|
||||
except:
|
||||
self.listening = reactor.listenSSL(self.config['port'], self.site, context, interface='0.0.0.0')
|
||||
self.base_url += 's'
|
||||
else:
|
||||
try:
|
||||
self.listening = reactor.listenTCP(self.config['port'], self.site, interface=self.config['ip'])
|
||||
except:
|
||||
self.listening = reactor.listenTCP(self.config['port'], self.site, interface='0.0.0.0')
|
||||
|
||||
port = self.config['port']
|
||||
ip = self.config['ip']
|
||||
elif self.config['serve_method'] == 'webui': # this webserver is fubar
|
||||
plugin_manager = component.get("CorePluginManager")
|
||||
|
||||
webui_plugin = plugin_manager['WebUi'].plugin
|
||||
webui_plugin.server.top_level.putChild('streaming', resource)
|
||||
|
||||
port = webui_plugin.server.port
|
||||
ip = getattr(webui_plugin.server, 'interface', None) or self.config['ip']
|
||||
if webui_plugin.server.https:
|
||||
self.base_url += 's'
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
self.base_url += '://'
|
||||
if ':' in ip:
|
||||
self.base_url += ip
|
||||
else:
|
||||
self.base_url += '%s:%s' % (ip, port)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def disable(self):
|
||||
self.site.stopFactory()
|
||||
self.torrent_handler.shutdown()
|
||||
yield self.listening.stopListening()
|
||||
|
||||
plugin_manager = component.get("CorePluginManager")
|
||||
webui_plugin = plugin_manager['WebUi'].plugin
|
||||
|
||||
try:
|
||||
webui_plugin.server.top_level.delEntity('streaming')
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if self.listening:
|
||||
yield self.listening.stopListening()
|
||||
self.listening = None
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def check_ssl(self):
|
||||
if self.config['ssl_source'] == 'daemon':
|
||||
return True
|
||||
|
||||
if not os.path.isfile(self.config['ssl_priv_key_path']) or not os.access(self.config['ssl_priv_key_path'], os.R_OK):
|
||||
return False
|
||||
|
||||
if not os.path.isfile(self.config['ssl_cert_path']) or not os.access(self.config['ssl_cert_path'], os.R_OK):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def check_webui(self):
|
||||
plugin_manager = component.get("CorePluginManager")
|
||||
return 'WebUi' in plugin_manager.get_enabled_plugins()
|
||||
|
||||
def check_config(self):
|
||||
pass
|
||||
|
||||
@export
|
||||
@defer.inlineCallbacks
|
||||
def set_config(self, config):
|
||||
"""Sets the config dictionary"""
|
||||
self.previous_config = copy(self.config)
|
||||
|
||||
for key in config.keys():
|
||||
self.config[key] = config[key]
|
||||
self.config.save()
|
||||
|
||||
yield self.disable()
|
||||
self.enable()
|
||||
|
||||
if self.config['serve_method'] == 'standalone' and self.config['ssl_source'] == 'custom' and self.config['use_ssl']:
|
||||
if not self.check_ssl():
|
||||
defer.returnValue(('error', 'ssl', 'SSL not enabled, make sure the private key and certificate exist and are accessible'))
|
||||
|
||||
@export
|
||||
def get_config(self):
|
||||
@@ -582,7 +687,7 @@ class Core(CorePluginBase):
|
||||
|
||||
@export
|
||||
@defer.inlineCallbacks
|
||||
def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None):
|
||||
def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None, includes_name=False, wait_for_end_pieces=False):
|
||||
tor = component.get("TorrentManager").torrents.get(infohash, None)
|
||||
|
||||
if tor is None:
|
||||
@@ -604,14 +709,18 @@ class Core(CorePluginBase):
|
||||
defer.returnValue({'status': 'error', 'message': 'failed to add torrent'})
|
||||
|
||||
try:
|
||||
tf = self.torrent_handler.get_stream(infohash, filepath_or_index)
|
||||
tf = self.torrent_handler.get_stream(infohash, filepath_or_index, includes_name)
|
||||
except UnknownTorrentException:
|
||||
defer.returnValue({'status': 'error', 'message': 'unable to find torrent, probably failed to add it'})
|
||||
|
||||
if wait_for_end_pieces:
|
||||
logger.debug('Waiting for end pieces')
|
||||
yield tf.wait_for_end_pieces()
|
||||
|
||||
defer.returnValue({
|
||||
'status': 'success',
|
||||
'use_stream_urls': self.config['use_stream_urls'],
|
||||
'auto_open_stream_urls': self.config['auto_open_stream_urls'],
|
||||
'url': 'http://%s:%s/file/%s/%s' % (self.config.config['ip'], self.config.config['port'],
|
||||
self.fsr.add_file(tf), urllib.quote_plus(os.path.basename(tf.path)))
|
||||
'url': '%s/streaming/file/%s/%s' % (self.base_url, self.fsr.add_file(tf),
|
||||
urllib.quote_plus(os.path.basename(tf.path).encode('utf-8')))
|
||||
})
|
||||
@@ -1,198 +1,590 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.5 on Fri Aug 8 23:34:44 2008 -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.16 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<widget class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="prefs_box">
|
||||
<widget class="GtkVBox" id="prefs_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="label_box">
|
||||
<widget class="GtkFrame" id="settings_frame">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_ip">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">IP:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_port">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Port:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_use_stream_urls">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Use stream urls:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_auto_open_stream_urls">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Auto-open stream urls:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_reset_complete">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Reset "do not download" when streamed file is complete:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_allow_remote">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Allow remote control:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_remote_username">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Remote username:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_remote_password">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Remote password:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="settings_alignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="top_padding">10</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="settings_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_download_only_streamed">
|
||||
<property name="label" translatable="yes">Download only streamed files, skip the other files</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="settings_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Settings</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="input_box">
|
||||
<widget class="GtkFrame" id="serving_frame">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_ip">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_port">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_use_stream_urls">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_auto_open_stream_urls">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_reset_complete">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_allow_remote">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_remote_username">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_remote_password">
|
||||
<property name="visible">True</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="settings_alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="top_padding">10</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="settings_vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="remote_username_label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Hostname: </property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_ip">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="remote_username_label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Port: </property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_port">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="input_serve_webui">
|
||||
<property name="label" translatable="yes">Serve files via WebUI</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="settings_vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="input_serve_standalone">
|
||||
<property name="label" translatable="yes">Serve files via standalone</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">input_serve_webui</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="remote_alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="remote_vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_use_ssl">
|
||||
<property name="label" translatable="yes">Use SSL</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="input_ssl_cert_daemon">
|
||||
<property name="label" translatable="yes">Use Daemon/WebUI Certificate</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="input_ssl_cert_custom">
|
||||
<property name="label" translatable="yes">Custom Certificate</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">input_ssl_cert_daemon</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Private key file path</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_ssl_priv_key_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Certificate and chains file path</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_ssl_cert_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="serving_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>File Serving Settings</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">7</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkFrame" id="settings_frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="settings_alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="top_padding">10</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="settings_vbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="settings_vbox5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_allow_remote">
|
||||
<property name="label" translatable="yes">Allow remote control</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="remote_alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">32</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="remote_vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="remote_username_hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="remote_username_label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Remote control username:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_remote_username">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="remote_password_hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="remote_password_label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Remote control password:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="input_remote_password">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_use_stream_urls">
|
||||
<property name="label" translatable="yes">Use stream urls</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="input_auto_open_stream_urls">
|
||||
<property name="label" translatable="yes">Auto-open stream urls</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="settings_label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Advanced Settings</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@@ -35,6 +35,8 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
||||
title: 'Streaming',
|
||||
border: false,
|
||||
layout: 'form',
|
||||
autoScroll: true,
|
||||
_fields: {},
|
||||
|
||||
initComponent: function() {
|
||||
PreferencePage.superclass.initComponent.call(this);
|
||||
@@ -45,7 +47,26 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
||||
var fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
title: 'Streaming',
|
||||
title: 'Settings',
|
||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 1,
|
||||
defaultType: 'textfield',
|
||||
defaults: {
|
||||
width: 180,
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('download_only_streamed', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'download_only_streamed',
|
||||
boxLabel: 'Download only streamed files, skip the other files',
|
||||
}));
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
title: 'File Serving Settings',
|
||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 110,
|
||||
@@ -55,71 +76,210 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('ip', fieldset.add({
|
||||
name: 'ip',
|
||||
fieldLabel: 'Hostname',
|
||||
}));
|
||||
|
||||
om.bind('port', fieldset.add({
|
||||
name: 'port',
|
||||
fieldLabel: _('Port'),
|
||||
decimalPrecision: 0,
|
||||
minValue: -1,
|
||||
maxValue: 99999
|
||||
maxValue: 99999,
|
||||
}));
|
||||
|
||||
om.bind('ip', fieldset.add({
|
||||
name: 'ip',
|
||||
fieldLabel: 'IP'
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
autoHeight: true,
|
||||
defaultType: 'radio',
|
||||
style: 'margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
|
||||
width: 240,
|
||||
labelWidth: 1
|
||||
});
|
||||
|
||||
this._fields['serve_method_webui'] = fieldset.add({
|
||||
name: 'serve_method',
|
||||
boxLabel: 'Serve files via WebUI',
|
||||
inputValue: 'webui',
|
||||
disabled: true
|
||||
});
|
||||
|
||||
om.bind('serve_method', this._fields['serve_method_webui']);
|
||||
|
||||
this._fields['serve_method_standalone'] = fieldset.add({
|
||||
name: 'serve_method',
|
||||
boxLabel: 'Serve files via standalone',
|
||||
inputValue: 'standalone',
|
||||
disabled: true
|
||||
});
|
||||
om.bind('serve_method', this._fields['serve_method_standalone']);
|
||||
|
||||
|
||||
om.bind('use_ssl', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'use_ssl',
|
||||
boxLabel: 'Use SSL',
|
||||
style: 'margin-left: 12px;'
|
||||
}));
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
autoHeight: true,
|
||||
defaultType: 'radio',
|
||||
style: 'margin-left: 24px; margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
|
||||
width: 240,
|
||||
labelWidth: 1
|
||||
});
|
||||
|
||||
this._fields['ssl_source_daemon'] = fieldset.add({
|
||||
name: 'ssl_source',
|
||||
boxLabel: 'Use Daemon/WebUI Certificate',
|
||||
inputValue: 'daemon',
|
||||
value: 'daemon'
|
||||
})
|
||||
om.bind('ssl_source', this._fields['ssl_source_daemon']);
|
||||
|
||||
this._fields['ssl_source_custom'] = fieldset.add({
|
||||
name: 'ssl_source',
|
||||
boxLabel: 'Custom Certificate',
|
||||
inputValue: 'custom',
|
||||
value: 'custom'
|
||||
});
|
||||
om.bind('ssl_source', this._fields['ssl_source_custom']);
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
style: 'margin-left: 24px; margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 110,
|
||||
defaultType: 'textfield',
|
||||
defaults: {
|
||||
width: 130,
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('ssl_priv_key_path', fieldset.add({
|
||||
name: 'ssl_priv_key_path',
|
||||
fieldLabel: 'Private key file path'
|
||||
}));
|
||||
|
||||
om.bind('ssl_cert_path', fieldset.add({
|
||||
name: 'ssl_cert_path',
|
||||
fieldLabel: 'Certificate and chains file path'
|
||||
}));
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
title: 'Advanced settings',
|
||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 1,
|
||||
defaultType: 'textfield',
|
||||
defaults: {
|
||||
width: 180,
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('allow_remote', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'allow_remote',
|
||||
boxLabel: 'Allow remote control',
|
||||
style: 'margin-left: 12px;'
|
||||
}));
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 110,
|
||||
defaultType: 'textfield',
|
||||
defaults: {
|
||||
width: 180,
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('remote_username', fieldset.add({
|
||||
xtype: 'textfield',
|
||||
name: 'remote_username',
|
||||
fieldLabel: 'Remote control username'
|
||||
}));
|
||||
|
||||
om.bind('remote_password', fieldset.add({
|
||||
xtype: 'textfield',
|
||||
name: 'remote_password',
|
||||
fieldLabel: 'Remote control password'
|
||||
}));
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||
autoHeight: true,
|
||||
labelWidth: 1,
|
||||
defaultType: 'textfield',
|
||||
defaults: {
|
||||
width: 180,
|
||||
}
|
||||
});
|
||||
|
||||
om.bind('use_stream_urls', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'use_stream_urls',
|
||||
fieldLabel: 'Use StreamProtocol urls',
|
||||
boxLabel: 'Use stream urls',
|
||||
style: 'margin-left: 12px;'
|
||||
}));
|
||||
|
||||
om.bind('auto_open_stream_urls', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'auto_open_stream_urls',
|
||||
fieldLabel: 'AutoOpen StreamProtocol urls',
|
||||
}));
|
||||
|
||||
om.bind('reset_complete', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'reset_complete',
|
||||
fieldLabel: 'Reset "do not download" when streamed file is complete',
|
||||
}));
|
||||
|
||||
om.bind('allow_remote', fieldset.add({
|
||||
xtype: 'checkbox',
|
||||
name: 'allow_remote',
|
||||
fieldLabel: 'Allow remote control checkbox',
|
||||
}));
|
||||
|
||||
om.bind('remote_username', fieldset.add({
|
||||
name: 'remote_username',
|
||||
fieldLabel: 'Remote username'
|
||||
}));
|
||||
|
||||
om.bind('remote_password', fieldset.add({
|
||||
name: 'remote_password',
|
||||
inputType: 'password',
|
||||
fieldLabel: 'Remote password'
|
||||
boxLabel: 'Auto-open stream urls',
|
||||
style: 'margin-left: 12px;'
|
||||
}));
|
||||
},
|
||||
|
||||
onApply: function() {
|
||||
|
||||
var changed = this.optionsManager.getDirty();
|
||||
for (var key in this._fields) {
|
||||
if (this._fields.hasOwnProperty(key)) {
|
||||
var v = this._fields[key];
|
||||
if (v.checked) {
|
||||
changed[v.name] = v.inputValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Ext.isObjectEmpty(changed)) {
|
||||
deluge.client.streaming.set_config(changed, {
|
||||
success: this.onSetConfig,
|
||||
scope: this
|
||||
});
|
||||
|
||||
|
||||
for (var key in deluge.config) {
|
||||
deluge.config[key] = this.optionsManager.get(key);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onSetConfig: function() {
|
||||
onSetConfig: function(result) {
|
||||
this.optionsManager.commit();
|
||||
if (result) {
|
||||
var message_type = result[0];
|
||||
var message_class = result[1];
|
||||
var message = result[2];
|
||||
if (message_type == 'error') {
|
||||
var topic = 'Unknown error type'
|
||||
if (message_class == 'ssl') {
|
||||
topic = 'SSL Failed'
|
||||
}
|
||||
Ext.Msg.alert(topic, message);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onGotConfig: function(config) {
|
||||
@@ -151,7 +311,7 @@ StreamingPlugin = Ext.extend(Deluge.Plugin, {
|
||||
|
||||
console.log('Streaming plugin loaded');
|
||||
var doStream = function (tid, fileIndex) {
|
||||
deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, {
|
||||
deluge.client.streaming.stream_torrent(tid, null, null, fileIndex, true, {
|
||||
success: function (result) {
|
||||
console.log('Got result', result);
|
||||
if (result.status == 'success') {
|
||||
|
||||
@@ -132,26 +132,52 @@ class GtkUI(GtkPluginBase):
|
||||
|
||||
torrentmenu = component.get("MenuBar").torrentmenu
|
||||
|
||||
file_menu.remove(self.item_torrentmenu)
|
||||
file_menu.remove(self.sep_torrentmenu)
|
||||
torrentmenu.remove(self.item_torrentmenu)
|
||||
torrentmenu.remove(self.sep_torrentmenu)
|
||||
|
||||
self.site.stopFactory()
|
||||
yield self.listening.stopListening()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def on_apply_prefs(self):
|
||||
log.debug("applying prefs for Streaming")
|
||||
|
||||
if self.glade.get_widget("input_serve_standalone").get_active():
|
||||
serve_method = 'standalone'
|
||||
elif self.glade.get_widget("input_serve_webui").get_active():
|
||||
serve_method = 'webui'
|
||||
|
||||
if self.glade.get_widget("input_ssl_cert_daemon").get_active():
|
||||
ssl_source = 'daemon'
|
||||
elif self.glade.get_widget("input_ssl_cert_custom").get_active():
|
||||
ssl_source = 'custom'
|
||||
|
||||
config = {
|
||||
"ip": self.glade.get_widget("input_ip").get_text(),
|
||||
"port": int(self.glade.get_widget("input_port").get_text()),
|
||||
"use_stream_urls": self.glade.get_widget("input_use_stream_urls").get_active(),
|
||||
"auto_open_stream_urls": self.glade.get_widget("input_auto_open_stream_urls").get_active(),
|
||||
"allow_remote": self.glade.get_widget("input_allow_remote").get_active(),
|
||||
"reset_complete": self.glade.get_widget("input_reset_complete").get_active(),
|
||||
"download_only_streamed": self.glade.get_widget("input_download_only_streamed").get_active(),
|
||||
"use_ssl": self.glade.get_widget("input_use_ssl").get_active(),
|
||||
"remote_username": self.glade.get_widget("input_remote_username").get_text(),
|
||||
"remote_password": self.glade.get_widget("input_remote_password").get_text(),
|
||||
"ssl_priv_key_path": self.glade.get_widget("input_ssl_priv_key_path").get_text(),
|
||||
"ssl_cert_path": self.glade.get_widget("input_ssl_cert_path").get_text(),
|
||||
"serve_method": serve_method,
|
||||
"ssl_source": ssl_source,
|
||||
}
|
||||
|
||||
client.streaming.set_config(config)
|
||||
result = yield client.streaming.set_config(config)
|
||||
|
||||
if result:
|
||||
message_type, message_class, message = result
|
||||
if message_type == 'error':
|
||||
topic = 'Unknown error type'
|
||||
if message_class == 'ssl':
|
||||
topic = 'SSL Failed'
|
||||
|
||||
dialogs.ErrorDialog(topic, message).run()
|
||||
|
||||
def on_show_prefs(self):
|
||||
client.streaming.get_config().addCallback(self.cb_get_config)
|
||||
@@ -163,9 +189,18 @@ class GtkUI(GtkPluginBase):
|
||||
self.glade.get_widget("input_use_stream_urls").set_active(config["use_stream_urls"])
|
||||
self.glade.get_widget("input_auto_open_stream_urls").set_active(config["auto_open_stream_urls"])
|
||||
self.glade.get_widget("input_allow_remote").set_active(config["allow_remote"])
|
||||
self.glade.get_widget("input_reset_complete").set_active(config["reset_complete"])
|
||||
self.glade.get_widget("input_use_ssl").set_active(config["use_ssl"])
|
||||
self.glade.get_widget("input_download_only_streamed").set_active(config["download_only_streamed"])
|
||||
self.glade.get_widget("input_remote_username").set_text(config["remote_username"])
|
||||
self.glade.get_widget("input_remote_password").set_text(config["remote_password"])
|
||||
self.glade.get_widget("input_ssl_priv_key_path").set_text(config["ssl_priv_key_path"])
|
||||
self.glade.get_widget("input_ssl_cert_path").set_text(config["ssl_cert_path"])
|
||||
|
||||
self.glade.get_widget("input_serve_standalone").set_active(config["serve_method"] == "standalone")
|
||||
self.glade.get_widget("input_serve_webui").set_active(config["serve_method"] == "webui")
|
||||
|
||||
self.glade.get_widget("input_ssl_cert_daemon").set_active(config["ssl_source"] == "daemon")
|
||||
self.glade.get_widget("input_ssl_cert_custom").set_active(config["ssl_source"] == "custom")
|
||||
|
||||
def stream_ready(self, result):
|
||||
if result['status'] == 'success':
|
||||
@@ -192,7 +227,7 @@ class GtkUI(GtkPluginBase):
|
||||
|
||||
for select in selected:
|
||||
path = ft.get_file_path(select)
|
||||
client.streaming.stream_torrent(infohash=torrent_id, filepath_or_index=path).addCallback(self.stream_ready)
|
||||
client.streaming.stream_torrent(infohash=torrent_id, filepath_or_index=path, includes_name=True).addCallback(self.stream_ready)
|
||||
break
|
||||
|
||||
def on_torrentmenu_menuitem_stream(self, data=None):
|
||||
|
||||
Reference in New Issue
Block a user