Expose torrent_handler.prioritize_files method
yevgenb opened this issue · comments
Steve, could you expose this method via http? That way we could play selected file from multi-file torrent.
Thanks!
The issue is that in sequential download, prioritizing pieces doesn't work in libtorrent (only download/do not download).
So it would really need to first download the file, then mark the other as downloading.
there are two methods - prioritize_pieces and prioritize_files. Is it same for prioritize_files - doesn't work for seqential download?
Actually, prioritize_files
is kind of a small helper method for prioritize_pieces
(because files are mapped to pieces).
The only way I got this to work that mark other pieces as do not download, then wait for them to be completed, which kind of kills the speed too :(
Here is function that works for python-rasterbar bindings in the similar project:
def startSession(self, contentId = 0, seeding = True):
self.initSession()
if None == self.magnetLink:
self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo, 'save_p
else:
self.torrentFileInfo = self.getMagnetInfo()
selectedFileInfo = self.getContentList()[contentId]
self.partOffset = 50 * 1024 * 1024 / self.torrentFileInfo.piece_length()#50 MB
#print 'partOffset ' + str(self.partOffset)
self.startPart = selectedFileInfo.offset / self.torrentFileInfo.piece_length()
self.endPart = (selectedFileInfo.offset + selectedFileInfo.size) / self.torrentFileInf
for i in range(self.torrentFileInfo.num_pieces()):
self.torrentHandle.piece_priority(i, 0)
for i in range(self.startPart, self.startPart + self.partOffset):
if i <= self.endPart:
self.torrentHandle.piece_priority(i, 7)
self.torrentHandle.piece_priority(self.endPart, 7)
self.torrentHandle.set_sequential_download(True)
thread.start_new_thread(self.downloadProcess, (contentId,))
if seeding:# and None == self.magnetLink:
thread.start_new_thread(self.addToSeeding, ())
Yes, he is only selecting the file he wants by marking the other files as "do not download" (priority 0).
This what I did in the early versions: e91310a#diff-70e2453d16a20c27de8ec4aabab47988R111
Hmm... Not a nice solution, but maybe we can start from that and set the normal priority after the selected file completed?