mirror of
https://github.com/JohnDoee/deluge-streaming/
synced 2026-07-01 07:31:17 -07:00
fixed bug related to path streaming
This commit is contained in:
@@ -41,6 +41,10 @@ The _allow remote_ option is to allow remote add and stream of torrents.
|
|||||||
|
|
||||||
# Version Info
|
# Version Info
|
||||||
|
|
||||||
|
## Version 0.5.0
|
||||||
|
* Restructured the whole plugin
|
||||||
|
* Added support for StreamProtocol
|
||||||
|
|
||||||
## Version 0.4.1
|
## Version 0.4.1
|
||||||
* Fixed bug with old Deluge versions
|
* Fixed bug with old Deluge versions
|
||||||
|
|
||||||
@@ -58,4 +62,4 @@ The _allow remote_ option is to allow remote add and stream of torrents.
|
|||||||
* Improved buffering algorithm, not using only deadline anymore.
|
* Improved buffering algorithm, not using only deadline anymore.
|
||||||
|
|
||||||
## Version 0.1
|
## Version 0.1
|
||||||
* Initial working release
|
* Initial working release
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -42,7 +42,7 @@ from setuptools import setup
|
|||||||
__plugin_name__ = "Streaming"
|
__plugin_name__ = "Streaming"
|
||||||
__author__ = "John Doee"
|
__author__ = "John Doee"
|
||||||
__author_email__ = "johndoee@tidalstream.org"
|
__author_email__ = "johndoee@tidalstream.org"
|
||||||
__version__ = "0.4.1"
|
__version__ = "0.5.0"
|
||||||
__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."
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ class TorrentFile(object): # can be read from, knows about itself
|
|||||||
logger.debug('Got data for piece %i, but no data needed for this piece?' % alert.piece)
|
logger.debug('Got data for piece %i, but no data needed for this piece?' % alert.piece)
|
||||||
return
|
return
|
||||||
# TODO: check piece size is not zero
|
# TODO: check piece size is not zero
|
||||||
|
|
||||||
self.waiting_pieces[alert.piece].callback(alert.buffer)
|
self.waiting_pieces[alert.piece].callback(alert.buffer)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@@ -293,8 +294,13 @@ class Torrent(object):
|
|||||||
first_piece = f['offset'] / piece_length
|
first_piece = f['offset'] / piece_length
|
||||||
last_piece = (f['offset'] + f['size']) / piece_length
|
last_piece = (f['offset'] + f['size']) / piece_length
|
||||||
full_path = os.path.join(save_path, f['path'])
|
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'],
|
self.torrent_files.append(TorrentFile(self, first_piece, last_piece, piece_length, f['offset'],
|
||||||
f['path'], full_path, f['size'], f['index']))
|
path, full_path, f['size'], f['index']))
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
@@ -303,6 +309,7 @@ class Torrent(object):
|
|||||||
biggest_file_size = 0
|
biggest_file_size = 0
|
||||||
|
|
||||||
for i, f in enumerate(self.torrent_files):
|
for i, f in enumerate(self.torrent_files):
|
||||||
|
logger.debug('Testing file %r against %s / %r' % (file_or_index, i, f.path))
|
||||||
if file_or_index is not None:
|
if file_or_index is not None:
|
||||||
if i == file_or_index or f.path == file_or_index:
|
if i == file_or_index or f.path == file_or_index:
|
||||||
best_file = f
|
best_file = f
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ class NoRangeStaticProducer(static.NoRangeStaticProducer):
|
|||||||
def resumeProducing(self):
|
def resumeProducing(self):
|
||||||
if not self.request:
|
if not self.request:
|
||||||
return
|
return
|
||||||
|
|
||||||
data = yield defer.maybeDeferred(self.fileObject.read, self.bufferSize)
|
data = yield defer.maybeDeferred(self.fileObject.read, self.bufferSize)
|
||||||
|
|
||||||
|
if not self.request:
|
||||||
|
return
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
# this .write will spin the reactor, calling .doWrite and then
|
# this .write will spin the reactor, calling .doWrite and then
|
||||||
# .resumeProducing again, so be prepared for a re-entrant call
|
# .resumeProducing again, so be prepared for a re-entrant call
|
||||||
@@ -27,13 +32,19 @@ class SingleRangeStaticProducer(static.SingleRangeStaticProducer):
|
|||||||
def resumeProducing(self):
|
def resumeProducing(self):
|
||||||
if not self.request:
|
if not self.request:
|
||||||
return
|
return
|
||||||
|
|
||||||
data = yield defer.maybeDeferred(self.fileObject.read,
|
data = yield defer.maybeDeferred(self.fileObject.read,
|
||||||
min(self.bufferSize, self.size - self.bytesWritten))
|
min(self.bufferSize, self.size - self.bytesWritten))
|
||||||
|
|
||||||
|
if not self.request:
|
||||||
|
return
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
self.bytesWritten += len(data)
|
self.bytesWritten += len(data)
|
||||||
# this .write will spin the reactor, calling .doWrite and then
|
# this .write will spin the reactor, calling .doWrite and then
|
||||||
# .resumeProducing again, so be prepared for a re-entrant call
|
# .resumeProducing again, so be prepared for a re-entrant call
|
||||||
self.request.write(data)
|
self.request.write(data)
|
||||||
|
|
||||||
if self.request and self.bytesWritten == self.size:
|
if self.request and self.bytesWritten == self.size:
|
||||||
self.request.unregisterProducer()
|
self.request.unregisterProducer()
|
||||||
self.request.finish()
|
self.request.finish()
|
||||||
@@ -44,6 +55,7 @@ class MultipleRangeStaticProducer(static.MultipleRangeStaticProducer):
|
|||||||
def resumeProducing(self):
|
def resumeProducing(self):
|
||||||
if not self.request:
|
if not self.request:
|
||||||
return
|
return
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
dataLength = 0
|
dataLength = 0
|
||||||
done = False
|
done = False
|
||||||
@@ -64,7 +76,12 @@ class MultipleRangeStaticProducer(static.MultipleRangeStaticProducer):
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not self.request:
|
||||||
|
return
|
||||||
|
|
||||||
self.request.write(''.join(data))
|
self.request.write(''.join(data))
|
||||||
|
|
||||||
if done:
|
if done:
|
||||||
self.request.unregisterProducer()
|
self.request.unregisterProducer()
|
||||||
self.request.finish()
|
self.request.finish()
|
||||||
|
|||||||
Reference in New Issue
Block a user