little piece mp4 fix

pull/1/head
DiMartinoXBMC 2015-06-08 21:17:37 +03:00
parent e7642ca4b5
commit e4adaef1ae
4 changed files with 46 additions and 11 deletions

View File

@ -51,6 +51,30 @@ class Libtorrent:
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
'''dirname = os.path.join(xbmc.translatePath('special://home'), 'addons', 'plugin.video.torrenter',
'resources')
sys.path.insert(0, dirname)
try:
import resources.libtorrent as libtorrent
print 'Imported libtorrent v' + libtorrent.version + ' from python_libtorrent.'
except Exception, e:
print 'Error importing python_libtorrent. Exception: ' + str(e)
try:
from ctypes import *
cdll.LoadLibrary(os.path.join(dirname,'libtorrent.so'))
except Exception, e:
print 'Error importing by ctypes. Exception: ' + str(e)
try:
print 'Imported libtorrent v' + libtorrent.version + ' from python_libtorrent.'
except Exception, e:
print 'Error importing python_libtorrent. Exception: ' + str(e)
print 'Imported libtorrent v' + libtorrent.version + ' from ctypes.'''''
try:
import libtorrent
@ -334,7 +358,7 @@ class Libtorrent:
for i in range(self.torrentFileInfo.num_pieces()):
self.torrentHandle.piece_priority(i, 0)
def continueSession(self, contentId=0, Offset=0, seeding=False):
def continueSession(self, contentId=0, Offset=0, seeding=False, isMP4=False):
self.piece_length = self.torrentFileInfo.piece_length()
selectedFileInfo = self.getContentList()[contentId]
if not Offset:
@ -344,16 +368,18 @@ class Libtorrent:
self.startPart = selectedFileInfo['offset'] / self.piece_length
self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length)
#print 'part ' + str(self.startPart)+ str(' ')+ str(self.endPart)
pieceMB=float(self.piece_length) / (1024 * 1024)
multiplier=int(10/pieceMB)
#print 'continueSession: pieceMB '+str(pieceMB)+' multiplier '+str(multiplier)
for i in range(self.startPart, self.startPart + self.partOffset):
if i <= self.endPart:
self.torrentHandle.piece_priority(i, 7)
#print str(i)
self.torrentHandle.piece_priority(self.endPart - 1, 7)
self.torrentHandle.piece_priority(self.endPart, 7)
#thread.start_new_thread(self.checkProcess, ())
#thread.start_new_thread(self.downloadProcess, (contentId,))
#if seeding:# and None == self.magnetLink:
# thread.start_new_thread(self.addToSeeding, (contentId,))
if isMP4 and i%multiplier==0:
self.torrentHandle.piece_priority(self.endPart - i/multiplier, 7)
#print str(i)
if multiplier>=i:
self.torrentHandle.piece_priority(self.endPart - i, 7)
#print str(i)
def fetchParts(self):
priorities = self.torrentHandle.piece_priorities()

View File

@ -189,7 +189,16 @@ class TorrentPlayer(xbmc.Player):
self.fullSize = self.torrent.getFileSize(self.contentId)
Offset = calculate(self.fullSize)
#print 'Offset: '+str(Offset)
self.torrent.continueSession(self.contentId, Offset=Offset)
#mp4 fix
label = os.path.basename(self.torrent.getFilePath(self.contentId))
isMP4=False
if '.' in label:
ext=label.split('.')[-1]
if ext.lower()=='mp4':
isMP4=True
#print 'setup_torrent: '+str((self.contentId, Offset, isMP4, label, ext))
self.torrent.continueSession(self.contentId, Offset=Offset, isMP4=isMP4)
def buffer(self):
iterator = 0

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.torrenter" name="Torrenter" version="2.2.5" provider-name="vadim.skorba, DiMartino">
<addon id="plugin.video.torrenter" name="Torrenter" version="2.2.7" provider-name="vadim.skorba, DiMartino">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent"/>

View File

@ -75,7 +75,7 @@ class RiperAM(SearcherABC.SearcherABC):
if None != response and 0 < len(response):
self.cookieJar.save(ignore_discard=True)
self.check_login(response)
print response
#print response
dat = re.compile(
r'<a href="\.(/download/.+?)".+?<font size="3pt">(.+?)</font></a>.+?Размер: <b>(.+?)</b>.+?" title="Сидеров"><b>(\d+?)</b>.+?title="Личеров"><b>(\d+?)</b></span></dd>',
re.DOTALL | re.I).findall(response)