mirror of
https://github.com/JohnDoee/deluge-streaming/
synced 2026-07-01 07:31:17 -07:00
fixed compatibility issues and resume
This commit is contained in:
@@ -48,6 +48,7 @@ import deluge.configmanager
|
|||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from types import MethodType
|
||||||
|
|
||||||
from deluge import component, configmanager
|
from deluge import component, configmanager
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
@@ -88,6 +89,24 @@ DEFAULT_PREFS = {
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_torrent(infohash):
|
||||||
|
def get_file_priorities(self):
|
||||||
|
"""Return the file priorities"""
|
||||||
|
if not self.handle.has_metadata():
|
||||||
|
return []
|
||||||
|
|
||||||
|
if not self.options["file_priorities"]:
|
||||||
|
# Ensure file_priorities option is populated.
|
||||||
|
self.set_file_priorities([])
|
||||||
|
|
||||||
|
return self.options["file_priorities"]
|
||||||
|
|
||||||
|
torrent = component.get("TorrentManager").torrents.get(infohash, None)
|
||||||
|
if torrent and not hasattr(torrent, 'get_file_priorities'):
|
||||||
|
torrent.get_file_priorities = MethodType(get_file_priorities, torrent)
|
||||||
|
|
||||||
|
return torrent
|
||||||
|
|
||||||
|
|
||||||
class Torrent(object):
|
class Torrent(object):
|
||||||
def __init__(self, torrent_handler, infohash):
|
def __init__(self, torrent_handler, infohash):
|
||||||
@@ -99,7 +118,7 @@ class Torrent(object):
|
|||||||
self.cycle_lock = defer.DeferredLock()
|
self.cycle_lock = defer.DeferredLock()
|
||||||
self.last_activity = datetime.now()
|
self.last_activity = datetime.now()
|
||||||
|
|
||||||
self.torrent = component.get("TorrentManager").torrents.get(infohash, None)
|
self.torrent = get_torrent(infohash)
|
||||||
status = self.torrent.get_status(['piece_length'])
|
status = self.torrent.get_status(['piece_length'])
|
||||||
self.piece_length = status['piece_length']
|
self.piece_length = status['piece_length']
|
||||||
self.torrent.handle.set_sequential_download(True)
|
self.torrent.handle.set_sequential_download(True)
|
||||||
@@ -194,6 +213,8 @@ class Torrent(object):
|
|||||||
first_files.add(fileset['files'][0])
|
first_files.add(fileset['files'][0])
|
||||||
|
|
||||||
if found_not_started:
|
if found_not_started:
|
||||||
|
self.torrent.resume()
|
||||||
|
|
||||||
logger.debug('We had a fileset not started, must_whitelist:%r first_files:%r cannot_blacklist:%r' % (must_whitelist, first_files, cannot_blacklist))
|
logger.debug('We had a fileset not started, must_whitelist:%r first_files:%r cannot_blacklist:%r' % (must_whitelist, first_files, cannot_blacklist))
|
||||||
status = self.torrent.get_status(['files', 'file_progress'])
|
status = self.torrent.get_status(['files', 'file_progress'])
|
||||||
|
|
||||||
@@ -354,7 +375,7 @@ class TorrentHandler(object):
|
|||||||
self.cleanup_looping_call.stop()
|
self.cleanup_looping_call.stop()
|
||||||
|
|
||||||
def get_filesystem(self, infohash):
|
def get_filesystem(self, infohash):
|
||||||
torrent = component.get("TorrentManager").torrents.get(infohash, None)
|
torrent = get_torrent(infohash)
|
||||||
status = torrent.get_status(['piece_length', 'files', 'file_progress', 'save_path'])
|
status = torrent.get_status(['piece_length', 'files', 'file_progress', 'save_path'])
|
||||||
self.piece_length = status['piece_length']
|
self.piece_length = status['piece_length']
|
||||||
save_path = status['save_path']
|
save_path = status['save_path']
|
||||||
@@ -666,7 +687,7 @@ class Core(CorePluginBase):
|
|||||||
@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):
|
def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None, includes_name=False, wait_for_end_pieces=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 = component.get("TorrentManager").torrents.get(infohash, None)
|
torrent = get_torrent(infohash)
|
||||||
|
|
||||||
if torrent is None:
|
if torrent is None:
|
||||||
logger.info('Did not find torrent, must add it')
|
logger.info('Did not find torrent, must add it')
|
||||||
|
|||||||
@@ -204,15 +204,14 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
om.bind('remote_username', fieldset.add({
|
// om.bind('remote_username', fieldset.add({
|
||||||
xtype: 'textfield',
|
// xtype: 'textfield',
|
||||||
name: 'remote_username',
|
// name: 'remote_username',
|
||||||
fieldLabel: 'Remote control username'
|
// fieldLabel: 'Remote control username'
|
||||||
}));
|
// }));
|
||||||
|
|
||||||
om.bind('remote_password', fieldset.add({
|
om.bind('remote_password', fieldset.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
inputType: 'password',
|
|
||||||
name: 'remote_password',
|
name: 'remote_password',
|
||||||
fieldLabel: 'Remote control password'
|
fieldLabel: 'Remote control password'
|
||||||
}));
|
}));
|
||||||
@@ -308,7 +307,7 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
|||||||
var apiUrl = 'http';
|
var apiUrl = 'http';
|
||||||
if (optionsManager.get('use_ssl'))
|
if (optionsManager.get('use_ssl'))
|
||||||
apiUrl += 's';
|
apiUrl += 's';
|
||||||
apiUrl += '://' + optionsManager.get('ip') + ':' + optionsManager.get('port') + '/streaming/stream';
|
apiUrl += '://' + optionsManager.get('remote_username') + ':' + optionsManager.get('remote_password') + '@' + optionsManager.get('ip') + ':' + optionsManager.get('port') + '/streaming/stream';
|
||||||
Ext.getCmp('remote_url').setValue(apiUrl);
|
Ext.getCmp('remote_url').setValue(apiUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user