advancedsettings.xml
parent
e35dc7a06d
commit
92b56ca51f
|
@ -232,9 +232,9 @@ class BTClientPlayer(xbmc.Player):
|
|||
iterator = 0
|
||||
ready_list=[]
|
||||
status = self.c.get_normalized_status()
|
||||
conditions=[status['state'] in ['downloading', 'finished', 'seeding'], status['desired_rate'] > 0,
|
||||
conditions=[status['state'] in ['downloading', 'finished', 'seeding'], status['desired_rate'] > 0 or status['progress'] > 0.02,
|
||||
status['progress'] > 0,
|
||||
status['desired_rate'] > 0 and (status['download_rate'] > status['desired_rate'] or
|
||||
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:
|
||||
if cond:
|
||||
|
@ -341,11 +341,13 @@ class BTClientPlayer(xbmc.Player):
|
|||
while not response:
|
||||
xbmc.sleep(100)
|
||||
if response:
|
||||
xbmc.sleep(3000)
|
||||
#if 1==1:
|
||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||
playlist.clear()
|
||||
playlist.add(url, listitem)
|
||||
xbmc.Player().play(playlist)
|
||||
print "\nServing file on %s" % url
|
||||
xbmc.Player().play(playlist, listitem)
|
||||
log("Serving file on %s" % url)
|
||||
return True
|
||||
|
||||
def onPlayBackStarted(self):
|
||||
|
@ -368,6 +370,19 @@ class BTClientPlayer(xbmc.Player):
|
|||
f()
|
||||
log('[onPlayBackStopped]: '+(str(("video", "stop", self.display_name))))
|
||||
|
||||
|
||||
def onPlayBackSeek(self):
|
||||
log('[onPlayBackSeek]: '+(str(("video", "seek", self.display_name))))
|
||||
self.pause()
|
||||
self.buffer()
|
||||
self.play()
|
||||
|
||||
def onPlayBackSeekChapter(self):
|
||||
log('[onPlayBackSeek]: '+(str(("video", "seek", self.display_name))))
|
||||
self.pause()
|
||||
self.buffer()
|
||||
self.play()
|
||||
|
||||
@contextmanager
|
||||
def attach(self, callback, *events):
|
||||
for event in events:
|
||||
|
|
13
Core.py
13
Core.py
|
@ -71,16 +71,9 @@ class Core:
|
|||
|
||||
def sectionMenu(self):
|
||||
if self.__settings__.getSetting('plugin_name')!=self.__plugin__:
|
||||
if self.__plugin__ == 'Torrenter v.2.3.2':
|
||||
#first_run_230(self.__settings__.getSetting('delete_russian')=='true')
|
||||
first_run_231()
|
||||
if self.__settings__.getSetting('delete_russian')!='false':
|
||||
not_russian=delete_russian(ok=self.__settings__.getSetting('delete_russian')=='true', action='delete')
|
||||
if not_russian:
|
||||
self.__settings__.setSetting('delete_russian', 'true')
|
||||
self.__settings__.setSetting('language', '0')
|
||||
else:
|
||||
self.__settings__.setSetting('delete_russian', 'false')
|
||||
if self.__plugin__ == 'Torrenter v.2.3.7':
|
||||
#first_run_231()
|
||||
check_network_advancedsettings()
|
||||
self.__settings__.setSetting('plugin_name',self.__plugin__)
|
||||
|
||||
ListString = 'XBMC.RunPlugin(%s)' % (sys.argv[0] + '?action=%s&action2=%s&%s=%s')
|
||||
|
|
|
@ -267,7 +267,10 @@ def localize(text):
|
|||
'Ask to save':'Спросить о сохранении',
|
||||
'Would you like to save this file?':'Хотите сохранить данный файл?',
|
||||
'Your storage path is not writable or not local! Please change it in settings!':'Ваше хранилище не доступно для записи или не локально! Измените в настройках!',
|
||||
|
||||
'Upgrade advancedsettings.xml':'Обновление advancedsettings.xml',
|
||||
'We would like to set some advanced settings for you!':'Нам нужно обновить продвинутые настройки для работы!',
|
||||
'Do it!':'Скажите "ДА"!',
|
||||
'Please, restart Kodi now!':'Теперь перезагрузите Коди, пожалуйста!',
|
||||
},
|
||||
'uk': {
|
||||
'Seeds searching.': 'Йде пошук сідів.',
|
||||
|
|
71
functions.py
71
functions.py
|
@ -1748,3 +1748,74 @@ def chooseFile(filelist):
|
|||
|
||||
if ret > -1:
|
||||
return myshows_files[ret]
|
||||
|
||||
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':100, 'cachemembuffersize':252420, 'readbufferfactor':5}
|
||||
add, update = {}, {}
|
||||
|
||||
if not os.path.exists(path):
|
||||
updated=True
|
||||
file_cont='''<advancedsettings>
|
||||
<network>
|
||||
<buffermode>2</buffermode>
|
||||
<curlclienttimeout>100</curlclienttimeout>
|
||||
<cachemembuffersize>252420</cachemembuffersize>
|
||||
<readbufferfactor>5</readbufferfactor>
|
||||
</network>
|
||||
</advancedsettings>'''
|
||||
else:
|
||||
with open(path) as f:
|
||||
file_cont=f.read()
|
||||
|
||||
print str(file_cont)
|
||||
|
||||
if not updated and not re.search('<network>.+?</network>', file_cont, re.DOTALL):
|
||||
updated=True
|
||||
file_cont=file_cont.replace('<advancedsettings>',
|
||||
'''<advancedsettings>
|
||||
<network>
|
||||
<buffermode>2</buffermode>
|
||||
<curlclienttimeout>100</curlclienttimeout>
|
||||
<cachemembuffersize>252420</cachemembuffersize>
|
||||
<readbufferfactor>5</readbufferfactor>
|
||||
</network>
|
||||
</advancedsettings>''')
|
||||
elif not updated:
|
||||
for key in settings.keys():
|
||||
search=re.search('<'+key+'>(.+?)</'+key+'>', file_cont, re.DOTALL)
|
||||
if not search:
|
||||
add[key]=settings[key]
|
||||
elif int(search.group(1))<int(settings[key]):
|
||||
print str(int(search.group(1)))
|
||||
update[key]=settings[key]
|
||||
print str(add)
|
||||
print str(update)
|
||||
if len(add)>0 or len(update)>0:
|
||||
updated=True
|
||||
for key in add.keys():
|
||||
file_cont=file_cont.replace('<network>','<network>\r\n <'+key+'>'+str(add[key])+'</'+key+'>')
|
||||
for key in update.keys():
|
||||
file_cont=re.sub(r'<'+key+'>\d+</'+key+'>', '<'+key+'>'+str(update[key])+'</'+key+'>', file_cont)
|
||||
print str(file_cont)
|
||||
|
||||
if updated:
|
||||
dialog=xbmcgui.Dialog()
|
||||
ok=dialog.yesno(Localization.localize('Upgrade advancedsettings.xml'),
|
||||
Localization.localize('We would like to set some advanced settings for you!'),
|
||||
Localization.localize('Do it!'))
|
||||
if ok:
|
||||
print 'OUTPUT: '
|
||||
print str(file_cont)
|
||||
|
||||
f=open(path, mode='w')
|
||||
f.write(file_cont)
|
||||
f.close()
|
||||
dialog.ok(Localization.localize('Upgrade advancedsettings.xml'),
|
||||
Localization.localize('Please, restart Kodi now!'))
|
||||
print 'Restart Kodi'
|
||||
else:
|
||||
print 'UPDATE advancedsettings.xml disabled by user!'
|
||||
sys.exit(1)
|
|
@ -203,7 +203,7 @@ class BTClient(BaseClient):
|
|||
self.lt=lt
|
||||
self._cache = CacheBT(path_to_store, self.lt)
|
||||
self._torrent_params = {'save_path': path_to_store,
|
||||
'storage_mode': self.lt.storage_mode_t.storage_mode_sparse
|
||||
#'storage_mode': self.lt.storage_mode_t.storage_mode_sparse
|
||||
}
|
||||
if not state_file:
|
||||
state_file=os.path.join(path_to_store,'.btclient_state')
|
||||
|
@ -249,6 +249,7 @@ class BTClient(BaseClient):
|
|||
if s.state in [3, 4, 5] and not self._file and s.progress > 0:
|
||||
self._meta_ready(self._th.torrent_file())
|
||||
logger.debug('Got torrent metadata and start download')
|
||||
self.hash = True
|
||||
self.hash = Hasher(self._file, self._on_file_ready)
|
||||
|
||||
def _choose_file(self, files, i):
|
||||
|
@ -425,6 +426,7 @@ class BTClient(BaseClient):
|
|||
def close(self):
|
||||
self.remove_all_dispatcher_listeners()
|
||||
self._monitor.stop()
|
||||
self._cache.close()
|
||||
if self._ses:
|
||||
self._ses.pause()
|
||||
if self._th:
|
||||
|
@ -435,7 +437,7 @@ class BTClient(BaseClient):
|
|||
self._ses.remove_torrent(self._th)
|
||||
except:
|
||||
print 'RuntimeError: invalid torrent handle used'
|
||||
#BaseClient.close(self)
|
||||
BaseClient.close(self)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
|
@ -505,7 +507,6 @@ class BTClient(BaseClient):
|
|||
(self.lt.version, s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000,
|
||||
s.num_peers, state_str[s.state]))
|
||||
|
||||
|
||||
def get_normalized_status(self):
|
||||
s = self.status
|
||||
if self._file:
|
||||
|
|
|
@ -18,7 +18,7 @@ from hachoir_metadata import extractMetadata
|
|||
from hachoir_parser import guessParser
|
||||
import hachoir_core.config as hachoir_config
|
||||
from hachoir_core.stream.input import InputIOStream
|
||||
from opensubtitle import OpenSubtitles
|
||||
#from opensubtitle import OpenSubtitles
|
||||
|
||||
logger = logging.getLogger('common')
|
||||
hachoir_config.quiet = True
|
||||
|
@ -64,12 +64,48 @@ class Hasher(Thread):
|
|||
self.start()
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
with self._btfile.create_cursor() as c:
|
||||
filehash = OpenSubtitles.hash_file(c, self._btfile.size)
|
||||
self.hash = filehash
|
||||
self._hash_cb(filehash)
|
||||
|
||||
|
||||
class OpenSubtitles(object):
|
||||
USER_AGENT = 'BTClient'
|
||||
|
||||
def __init__(self, lang, user='', pwd=''):
|
||||
self._lang = lang
|
||||
self._token = None
|
||||
self._user = user
|
||||
self._pwd = pwd
|
||||
|
||||
@staticmethod
|
||||
def hash_file(f, filesize):
|
||||
import struct
|
||||
|
||||
longlongformat = '<q' # little-endian long long
|
||||
bytesize = struct.calcsize(longlongformat)
|
||||
|
||||
hash = filesize # @ReservedAssignment
|
||||
if filesize < 65536 * 2:
|
||||
raise ValueError("SizeError")
|
||||
|
||||
for _x in range(65536 / bytesize):
|
||||
buffer = f.read(bytesize) # @ReservedAssignment
|
||||
(l_value,) = struct.unpack(longlongformat, buffer)
|
||||
hash += l_value
|
||||
hash = hash & 0xFFFFFFFFFFFFFFFF # to remain as 64bit number @ReservedAssignment
|
||||
|
||||
f.seek(max(0, filesize - 65536))
|
||||
for _x in range(65536 / bytesize):
|
||||
buffer = f.read(bytesize) # @ReservedAssignment
|
||||
(l_value,) = struct.unpack(longlongformat, buffer)
|
||||
hash += l_value
|
||||
hash = hash & 0xFFFFFFFFFFFFFFFF # @ReservedAssignment
|
||||
returnedhash = "%016x" % hash
|
||||
return returnedhash
|
||||
|
||||
class BaseMonitor(Thread):
|
||||
def __init__(self, client, name):
|
||||
Thread.__init__(self, name=name)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Created on Apr 2, 2015
|
||||
|
||||
@author: ivan
|
||||
'''
|
||||
|
||||
import xmlrpclib
|
||||
import urllib2
|
||||
import os.path
|
||||
|
@ -259,3 +259,4 @@ if __name__ == '__main__':
|
|||
down(args.video_file, args.lang, args.overwrite)
|
||||
else:
|
||||
list_subs(args.video_file, args.lang)
|
||||
'''
|
Loading…
Reference in New Issue