From 8d1472bc8e0b69518b153c8fc70a3db59de57b26 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Fri, 7 Aug 2015 16:23:13 +0300 Subject: [PATCH] adv fix --- BTClientPlayer.py | 14 +++++++------- Core.py | 5 +++-- functions.py | 25 ++++++++++++++----------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/BTClientPlayer.py b/BTClientPlayer.py index 9abb2e4..c3f3957 100644 --- a/BTClientPlayer.py +++ b/BTClientPlayer.py @@ -228,12 +228,12 @@ class BTClientPlayer(xbmc.Player): progressBar = xbmcgui.DialogProgress() progressBar.create(self.localize('Please Wait') + str(' [%s]' % str(self.lt.version)), self.localize('Seeds searching.')) - while iterator < 100 or not self.c.is_file_ready:# not self.c.is_file_ready + while iterator < 100:# not self.c.is_file_ready iterator = 0 ready_list=[] status = self.c.get_normalized_status() conditions=[status['state'] in ['downloading', 'finished', 'seeding'], status['desired_rate'] > 0 or status['progress'] > 0.02, - status['progress'] > 0, + status['progress'] > 0.01, self.c.is_file_ready or status['progress'] > 0.02, status['desired_rate'] > 0 or status['progress'] > 0.02 and (status['download_rate'] > status['desired_rate'] or status['download_rate'] * status['progress'] * 100 > status['desired_rate'])] for cond in conditions: @@ -244,17 +244,17 @@ class BTClientPlayer(xbmc.Player): ready_list.append(False) speedsText = '%s: %s Mbit/s %s %s: %s Mbit/s' % (self.localize('Bitrate'), str(int(status['desired_rate'] * 8 / (1024 * 1024))) if status['desired_rate'] else 0, - '[COLOR=green]>[/COLOR]' if ready_list[3] else '[COLOR=red]<[/COLOR]', + '[COLOR=green]>[/COLOR]' if ready_list[4] else '[COLOR=red]<[/COLOR]', self.localize('Download speed'),str(status['download_rate'] * 8 / 1000000)) if status['state'] in ['queued','checking','checking fastresume'] or (status['progress'] == 0 and status['num_pieces'] > 0): progressBar.update(iterator, self.localize('Checking preloaded files...'), speedsText, ' ') elif status['state'] in ['downloading', 'finished', 'seeding']: - dialogText = self.localize('Preloaded: ') + '%s MB / %s MB' % \ - (str(status['downloaded'] / 1024 / 1024), str(status['total_size'] / 1024 / 1024)) - peersText = '[%s: %s; %s: %s]' % (self.localize('Seeds'), str(status['seeds_connected']), self.localize('Peers'), - str(status['peers_connected']),) + dialogText = self.localize('Preloaded: ') + '%s MB %s %s MB (%s MB)' % \ + (str(status['downloaded'] / 1024 / 1024), '[COLOR=green]>[/COLOR]' if ready_list[3] else '[COLOR=red]<[/COLOR]', str(status['total_size'] / 1024 / 1024 /100), str(status['total_size'] / 1024 / 1024)) + peersText = '[%s: %s; %s: %s] %s: %s' % (self.localize('Seeds'), str(status['seeds_connected']), self.localize('Peers'), + str(status['peers_connected']), self.localize('File ready: '), '[COLOR=green]YES[/COLOR]' if ready_list[2] else '[COLOR=red]NO[/COLOR]') progressBar.update(iterator, peersText, speedsText, dialogText, ) else: diff --git a/Core.py b/Core.py index 9d0bbce..2495e39 100644 --- a/Core.py +++ b/Core.py @@ -71,10 +71,11 @@ class Core: def sectionMenu(self): if self.__settings__.getSetting('plugin_name')!=self.__plugin__: + self.__settings__.setSetting('plugin_name',self.__plugin__) + check_network_advancedsettings() if self.__plugin__ == 'Torrenter v.2.3.7': #first_run_231() - check_network_advancedsettings() - self.__settings__.setSetting('plugin_name',self.__plugin__) + pass ListString = 'XBMC.RunPlugin(%s)' % (sys.argv[0] + '?action=%s&action2=%s&%s=%s') contextMenu = [(self.localize('Search Control Window'), diff --git a/functions.py b/functions.py index a66623d..174b612 100644 --- a/functions.py +++ b/functions.py @@ -1753,9 +1753,10 @@ def check_network_advancedsettings(): path=xbmc.translatePath('special://profile/advancedsettings.xml') updated=False #path='''C:\\Users\\Admin\\AppData\\Roaming\\Kodi\\userdata\\advancedsettings.xml''' - settings={'buffermode':2, 'curlclienttimeout':30, 'cachemembuffersize':252420, 'readbufferfactor':5} + settings={'buffermode':2, 'curlclienttimeout':30, 'cachemembuffersize':252420, 'readbufferfactor':5.0} add, update = {}, {} + if not os.path.exists(path): updated=True file_cont=''' @@ -1770,7 +1771,7 @@ def check_network_advancedsettings(): with open(path) as f: file_cont=f.read() - print str(file_cont) + log('[check_network_advancedsettings]: old file_cont '+str(file_cont)) if not updated and not re.search('.+?', file_cont, re.DOTALL): updated=True @@ -1788,11 +1789,15 @@ def check_network_advancedsettings(): search=re.search('<'+key+'>(.+?)', file_cont, re.DOTALL) if not search: add[key]=settings[key] - elif int(search.group(1))0 or len(update)>0: updated=True for key in add.keys(): @@ -1807,8 +1812,7 @@ def check_network_advancedsettings(): Localization.localize('We would like to set some advanced settings for you!'), Localization.localize('Do it!')) if ok: - print 'OUTPUT: ' - print str(file_cont) + log('[check_network_advancedsettings]: new file_cont '+str(file_cont)) f=open(path, mode='w') f.write(file_cont) @@ -1817,5 +1821,4 @@ def check_network_advancedsettings(): Localization.localize('Please, restart Kodi now!')) print 'Restart Kodi' else: - print 'UPDATE advancedsettings.xml disabled by user!' - sys.exit(1) \ No newline at end of file + print 'UPDATE advancedsettings.xml disabled by user!' \ No newline at end of file