Merge branch 'release/0.10.1'

This commit is contained in:
Anders Jensen
2018-08-25 09:55:31 +02:00
3 changed files with 28 additions and 22 deletions

View File

@@ -51,6 +51,9 @@ The _allow remote_ option is to allow remote add and stream of torrents.
# Version Info # Version Info
## Version 0.10.1
* Small bugfixes related to priorities, should actually make sequential download work.
## Version 0.10.0 ## Version 0.10.0
* Rewrote large parts of the code * Rewrote large parts of the code
* Now using [thomas](https://github.com/JohnDoee/thomas) as file-reading core - this adds support for multi-rar streaming. * Now using [thomas](https://github.com/JohnDoee/thomas) as file-reading core - this adds support for multi-rar streaming.

View File

@@ -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.0" __version__ = "0.10.1"
__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."

View File

@@ -70,6 +70,7 @@ VIDEO_STREAMABLE_EXTENSIONS = ['mkv', 'mp4', 'iso', 'ogg', 'ogm', 'm4v']
AUDIO_STREAMABLE_EXTENSIONS = ['flac', 'mp3', 'oga'] AUDIO_STREAMABLE_EXTENSIONS = ['flac', 'mp3', 'oga']
STREAMABLE_EXTENSIONS = set(VIDEO_STREAMABLE_EXTENSIONS + AUDIO_STREAMABLE_EXTENSIONS) STREAMABLE_EXTENSIONS = set(VIDEO_STREAMABLE_EXTENSIONS + AUDIO_STREAMABLE_EXTENSIONS)
TORRENT_CLEANUP_INTERVAL = timedelta(minutes=30) TORRENT_CLEANUP_INTERVAL = timedelta(minutes=30)
MAX_FILE_PRIORITY = 2
DEFAULT_PREFS = { DEFAULT_PREFS = {
'ip': '127.0.0.1', 'ip': '127.0.0.1',
@@ -164,10 +165,12 @@ class Torrent(object):
self.torrent.handle.piece_priority(needed_piece, 7) self.torrent.handle.piece_priority(needed_piece, 7)
f = self.get_file_from_offset(from_byte) f = self.get_file_from_offset(from_byte)
logger.debug('Also setting file to max %r' % (f, ))
file_priorities = self.torrent.get_file_priorities() file_priorities = self.torrent.get_file_priorities()
file_priorities[f['index']] = 7 if file_priorities[f['index']] != MAX_FILE_PRIORITY:
self.torrent.set_file_priorities(file_priorities) logger.debug('Also setting file to max %r' % (f, ))
file_priorities[f['index']] = MAX_FILE_PRIORITY
self.torrent.set_file_priorities(file_priorities)
for _ in range(300): for _ in range(300):
if self.torrent.status.pieces[needed_piece]: if self.torrent.status.pieces[needed_piece]:
@@ -239,7 +242,7 @@ class Torrent(object):
if f['path'] in must_whitelist: if f['path'] in must_whitelist:
if f['path'] in first_files: if f['path'] in first_files:
file_priorities[i] = 7 file_priorities[i] = MAX_FILE_PRIORITY
else: else:
file_priorities[i] = 1 file_priorities[i] = 1
elif f['path'] not in cannot_blacklist: elif f['path'] not in cannot_blacklist:
@@ -265,6 +268,23 @@ class Torrent(object):
else: else:
fileset_ranges[fileset_hash] = fileset['files'].index(path) fileset_ranges[fileset_hash] = fileset['files'].index(path)
file_priorities = self.torrent.get_file_priorities()
logger.debug('Fileset heads: %r' % (fileset_ranges, ))
for fileset_hash, first_file in fileset_ranges.items():
fileset = self.filesets[fileset_hash]
logger.debug('From index %s' % (first_file, ))
file_mapping = {f['path']: f['index'] for f in status['files']}
for i, f in enumerate(fileset['files']):
index = file_mapping[f]
if i < first_file:
file_priorities[index] = 0
elif i == first_file:
file_priorities[index] = MAX_FILE_PRIORITY
else:
file_priorities[index] = 1
self.torrent.set_file_priorities(file_priorities)
currently_downloading = self.get_currently_downloading() currently_downloading = self.get_currently_downloading()
logger.debug('File heads: %r' % (file_ranges, )) logger.debug('File heads: %r' % (file_ranges, ))
for f, progress in zip(status['files'], status['file_progress']): for f, progress in zip(status['files'], status['file_progress']):
@@ -296,23 +316,6 @@ class Torrent(object):
else: else:
self.torrent.handle.piece_priority(piece, 1) self.torrent.handle.piece_priority(piece, 1)
file_priorities = self.torrent.get_file_priorities()
logger.debug('Fileset heads: %r' % (fileset_ranges, ))
for fileset_hash, first_file in fileset_ranges.items():
fileset = self.filesets[fileset_hash]
logger.debug('From index %s' % (first_file, ))
file_mapping = {f['path']: f['index'] for f in status['files']}
for i, f in enumerate(fileset['files']):
index = file_mapping[f]
if i < first_file:
file_priorities[index] = 0
elif i == first_file:
file_priorities[index] = 7
else:
file_priorities[index] = 1
self.torrent.set_file_priorities(file_priorities)
def get_currently_downloading(self): def get_currently_downloading(self):
currently_downloading = set() currently_downloading = set()
for peer in self.torrent.handle.get_peer_info(): for peer in self.torrent.handle.get_peer_info():