advancedsettings.xml

This commit is contained in:
DiMartinoXBMC committed 2015-08-06 00:38:19 +03:00
1 parent e35dc7a06d
commit 92b56ca51f
7 files changed
+142 -22

No files matched your search

+4 -3
View File
@@ -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:
+37 -1
View 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 -1
View File
@@ -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)
'''