little piece mp4 fix
parent
e7642ca4b5
commit
e4adaef1ae
|
@ -51,6 +51,30 @@ class Libtorrent:
|
||||||
|
|
||||||
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
|
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:
|
try:
|
||||||
import libtorrent
|
import libtorrent
|
||||||
|
|
||||||
|
@ -334,7 +358,7 @@ class Libtorrent:
|
||||||
for i in range(self.torrentFileInfo.num_pieces()):
|
for i in range(self.torrentFileInfo.num_pieces()):
|
||||||
self.torrentHandle.piece_priority(i, 0)
|
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()
|
self.piece_length = self.torrentFileInfo.piece_length()
|
||||||
selectedFileInfo = self.getContentList()[contentId]
|
selectedFileInfo = self.getContentList()[contentId]
|
||||||
if not Offset:
|
if not Offset:
|
||||||
|
@ -344,16 +368,18 @@ class Libtorrent:
|
||||||
self.startPart = selectedFileInfo['offset'] / self.piece_length
|
self.startPart = selectedFileInfo['offset'] / self.piece_length
|
||||||
self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length)
|
self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length)
|
||||||
#print 'part ' + str(self.startPart)+ str(' ')+ str(self.endPart)
|
#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):
|
for i in range(self.startPart, self.startPart + self.partOffset):
|
||||||
if i <= self.endPart:
|
if i <= self.endPart:
|
||||||
self.torrentHandle.piece_priority(i, 7)
|
self.torrentHandle.piece_priority(i, 7)
|
||||||
#print str(i)
|
if isMP4 and i%multiplier==0:
|
||||||
self.torrentHandle.piece_priority(self.endPart - 1, 7)
|
self.torrentHandle.piece_priority(self.endPart - i/multiplier, 7)
|
||||||
self.torrentHandle.piece_priority(self.endPart, 7)
|
#print str(i)
|
||||||
#thread.start_new_thread(self.checkProcess, ())
|
if multiplier>=i:
|
||||||
#thread.start_new_thread(self.downloadProcess, (contentId,))
|
self.torrentHandle.piece_priority(self.endPart - i, 7)
|
||||||
#if seeding:# and None == self.magnetLink:
|
#print str(i)
|
||||||
# thread.start_new_thread(self.addToSeeding, (contentId,))
|
|
||||||
|
|
||||||
def fetchParts(self):
|
def fetchParts(self):
|
||||||
priorities = self.torrentHandle.piece_priorities()
|
priorities = self.torrentHandle.piece_priorities()
|
||||||
|
|
11
Player.py
11
Player.py
|
@ -189,7 +189,16 @@ class TorrentPlayer(xbmc.Player):
|
||||||
self.fullSize = self.torrent.getFileSize(self.contentId)
|
self.fullSize = self.torrent.getFileSize(self.contentId)
|
||||||
Offset = calculate(self.fullSize)
|
Offset = calculate(self.fullSize)
|
||||||
#print 'Offset: '+str(Offset)
|
#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):
|
def buffer(self):
|
||||||
iterator = 0
|
iterator = 0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?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>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.1.0"/>
|
<import addon="xbmc.python" version="2.1.0"/>
|
||||||
<import addon="script.module.libtorrent"/>
|
<import addon="script.module.libtorrent"/>
|
||||||
|
|
|
@ -75,7 +75,7 @@ class RiperAM(SearcherABC.SearcherABC):
|
||||||
if None != response and 0 < len(response):
|
if None != response and 0 < len(response):
|
||||||
self.cookieJar.save(ignore_discard=True)
|
self.cookieJar.save(ignore_discard=True)
|
||||||
self.check_login(response)
|
self.check_login(response)
|
||||||
print response
|
#print response
|
||||||
dat = re.compile(
|
dat = re.compile(
|
||||||
r'<a href="\.(/download/.+?)".+?<font size="3pt">(.+?)</font></a>.+?Размер: <b>(.+?)</b>.+?" title="Сидеров"><b>(\d+?)</b>.+?title="Личеров"><b>(\d+?)</b></span></dd>',
|
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)
|
re.DOTALL | re.I).findall(response)
|
||||||
|
|
Loading…
Reference in New Issue