speed & encryption

pull/1/head
DiMartinoXBMC 2015-08-02 20:25:23 +03:00
parent c38b65c643
commit 449dd4a202
2 changed files with 26 additions and 39 deletions

View File

@ -114,8 +114,8 @@ class BTClientPlayer(xbmc.Player):
except:
pass
args=Namespace(bt_download_limit=0,#KB
bt_upload_limit=0,
args=Namespace(bt_download_limit=self.download_limit,#KB
bt_upload_limit=self.upload_limit,
choose_subtitles=False,
clear_older=0,
debug_log='',#os.path.join(self.userStorageDirectory, 'log.txt'),
@ -136,6 +136,7 @@ class BTClientPlayer(xbmc.Player):
url=self.torrentUrl)
args=main(args) #config
self.free_port = args.port
log('BTClientPlayer: args '+str(args))
self.btclient=self.stream(args, BTClient)
@ -195,6 +196,7 @@ class BTClientPlayer(xbmc.Player):
log('Starting btclient - libtorrent version %s' % self.lt.version)
self.c.start_url(args.url)
self.setup_torrent()
if self.buffer():
f = self.c._file
@ -233,38 +235,23 @@ class BTClientPlayer(xbmc.Player):
self.on_playback_paused = []
self.on_playback_stopped = []
self.fullSize = 0
if self.__settings__.getSetting("upload_limit") == "":
self.upload_limit = 0.0
else:
self.upload_limit = float(self.__settings__.getSetting("upload_limit")) / 8 * 1024
if self.__settings__.getSetting("download_limit") == "":
self.download_limit = 0.0
else:
self.download_limit = float(self.__settings__.getSetting("download_limit")) / 8 * 1024
def setup_torrent(self):
self.torrent.initSession()
if self.__settings__.getSetting('encryption') == 'true':
self.torrent.encryptSession()
self.torrent.startSession()
upload_limit = self.__settings__.getSetting("upload_limit") if self.__settings__.getSetting(
"upload_limit") != "" else 0
if 0 < int(upload_limit):
self.torrent.setUploadLimit(int(upload_limit) * 1000000 / 8) # MBits/second
download_limit = self.__settings__.getSetting("download_limit") if self.__settings__.getSetting(
"download_limit") != "" else 0
if 0 < int(download_limit):
self.torrent.setDownloadLimit(
int(download_limit) * 1000000 / 8) # MBits/second
self.torrent.status = False
self.fullSize = self.torrent.getFileSize(self.contentId)
Offset = calculate(self.fullSize)
debug('Offset: '+str(Offset))
if self.subs_dl:
subs = self.torrent.getSubsIds(os.path.basename(self.torrent.getFilePath(self.contentId)))
if len(subs) > 0:
for ind, title in subs:
self.torrent.continueSession(ind)
# mp4 fix
label = os.path.basename(self.torrent.getFilePath(self.contentId))
isMP4 = False
if '.' in label and str(label.split('.')[-1]).lower() == 'mp4':
isMP4 = True
debug('setup_torrent: '+str((self.contentId, Offset, isMP4, label)))
self.torrent.continueSession(self.contentId, Offset=Offset, isMP4=isMP4)
self.c.encrypt()
#if self.subs_dl:
# subs = self.torrent.getSubsIds(os.path.basename(self.torrent.getFilePath(self.contentId)))
# if len(subs) > 0:
# for ind, title in subs:
# self.torrent.continueSession(ind)
def buffer(self):
#iterator = 0
@ -455,8 +442,8 @@ class BTClientPlayer(xbmc.Player):
return [
self.display_name.decode('utf-8'),
"%.2f%% %s" % (s.progress * 100, self.localize(STATE_STRS[s.state]).decode('utf-8')),
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate / 1000, self.localize('kb/s').decode('utf-8'),
s.upload_rate / 1000, self.localize('kb/s').decode('utf-8'),
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate / 1024, self.localize('kb/s').decode('utf-8'),
s.upload_rate / 1024, self.localize('kb/s').decode('utf-8'),
s.num_seeds, s.num_peers)
]

View File

@ -20,13 +20,13 @@
<setting id="storage" type="folder" label="30004" default=""/>
<setting id="keep_files" type="enum" label="30008" default="1" lvalues="30043|30044|30045"/>
<setting id="ask_dir" type="bool" label="30031" default="false" enable="!eq(-1,0)" />
<setting id="next_dl" type="bool" label="30013" default="true" visible="eq(-4,0)"/>
<setting id="upload_limit" type="number" label="30010" default="0" visible="eq(-5,0)"/>
<setting id="download_limit" type="number" label="30011" default="0" visible="eq(-6,0)"/>
<setting id="next_dl" type="bool" label="30013" default="true" visible="!eq(-4,1)+"/>
<setting id="upload_limit" type="number" label="30010" default="0" visible="!eq(-5,1)"/>
<setting id="download_limit" type="number" label="30011" default="0" visible="!eq(-6,1)"/>
<setting id="blank" type="text" label="30024" default="" visible="eq(-7,1)"/>
<setting id="subs_dl" type="bool" label="30029" default="true" visible="eq(-8,0)"/>
<setting id="keep_seeding" type="bool" label="30030" default="false" visible="eq(-9,0)" enable="eq(-7,1)"/>
<setting id="encryption" type="bool" label="30041" default="true" visible="eq(-10,0)"/>
<setting id="subs_dl" type="bool" label="30029" default="true" visible="!eq(-8,1)"/>
<setting id="keep_seeding" type="bool" label="30030" default="false" visible="!eq(-9,1)" enable="eq(-7,1)"/>
<setting id="encryption" type="bool" label="30041" default="true" visible="!eq(-10,1)"/>
</category>
<category label="Torrent-client">
<setting id="torrent_save" type="enum" label="50301" lvalues="50302|50303" default="0"/>