rus fixes
parent
5879013616
commit
09bb692650
|
@ -117,12 +117,6 @@ class AnteoLoader:
|
||||||
else:
|
else:
|
||||||
self.torrentFile = torrentFile
|
self.torrentFile = torrentFile
|
||||||
|
|
||||||
def __exit__(self):
|
|
||||||
log('on __exit__')
|
|
||||||
if self.engine:
|
|
||||||
self.engine.close()
|
|
||||||
log('__exit__ worked!')
|
|
||||||
|
|
||||||
def setup_engine(self):
|
def setup_engine(self):
|
||||||
encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED
|
encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED
|
||||||
|
|
||||||
|
@ -163,13 +157,15 @@ class AnteoLoader:
|
||||||
torrent = Libtorrent(self.storageDirectory, self.torrentFile)
|
torrent = Libtorrent(self.storageDirectory, self.torrentFile)
|
||||||
return torrent.getContentList()
|
return torrent.getContentList()
|
||||||
except:
|
except:
|
||||||
|
import traceback
|
||||||
|
log(traceback.format_exc())
|
||||||
return self.getContentList_engine()
|
return self.getContentList_engine()
|
||||||
|
|
||||||
def getContentList_engine(self):
|
def getContentList_engine(self):
|
||||||
self.setup_engine()
|
self.setup_engine()
|
||||||
files = []
|
files = []
|
||||||
filelist = []
|
filelist = []
|
||||||
with closing(self.engine):
|
try:
|
||||||
self.engine.start()
|
self.engine.start()
|
||||||
#media_types=[MediaType.VIDEO, MediaType.AUDIO, MediaType.SUBTITLES, MediaType.UNKNOWN]
|
#media_types=[MediaType.VIDEO, MediaType.AUDIO, MediaType.SUBTITLES, MediaType.UNKNOWN]
|
||||||
|
|
||||||
|
@ -196,6 +192,11 @@ class AnteoLoader:
|
||||||
stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
|
stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
|
||||||
'offset': fs.offset}
|
'offset': fs.offset}
|
||||||
filelist.append(stringdata)
|
filelist.append(stringdata)
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
log(traceback.format_exc())
|
||||||
|
finally:
|
||||||
|
self.engine.close()
|
||||||
return filelist
|
return filelist
|
||||||
|
|
||||||
def saveTorrent(self, torrentUrl):
|
def saveTorrent(self, torrentUrl):
|
||||||
|
@ -230,8 +231,6 @@ class AnteoLoader:
|
||||||
log('Unable to rename torrent file from %s to %s in AnteoLoader::saveTorrent. Exception: %s' %
|
log('Unable to rename torrent file from %s to %s in AnteoLoader::saveTorrent. Exception: %s' %
|
||||||
(torrentUrl, torrentFile, str(e)))
|
(torrentUrl, torrentFile, str(e)))
|
||||||
return
|
return
|
||||||
#else:
|
|
||||||
#torrentFile = torrentUrl
|
|
||||||
if xbmcvfs.exists(torrentFile) and not os.path.exists(torrentFile):
|
if xbmcvfs.exists(torrentFile) and not os.path.exists(torrentFile):
|
||||||
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
|
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||||
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
|
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
|
||||||
|
@ -287,10 +286,8 @@ class AnteoPlayer(xbmc.Player):
|
||||||
self.contentId = int(self.get("url"))
|
self.contentId = int(self.get("url"))
|
||||||
if self.get("seek"):
|
if self.get("seek"):
|
||||||
self.seek = int(self.get("seek"))
|
self.seek = int(self.get("seek"))
|
||||||
#self.torrent = AnteoLoader(self.userStorageDirectory, self.torrentUrl, self.torrentFilesDirectory)
|
|
||||||
self.init()
|
self.init()
|
||||||
self.setup_engine()
|
self.setup_engine()
|
||||||
#with closing(self.engine):
|
|
||||||
try:
|
try:
|
||||||
self.engine.start(self.contentId)
|
self.engine.start(self.contentId)
|
||||||
self.setup_nextep()
|
self.setup_nextep()
|
||||||
|
@ -316,7 +313,7 @@ class AnteoPlayer(xbmc.Player):
|
||||||
continue
|
continue
|
||||||
log('['+author+'Player]: ************************************* NO! break')
|
log('['+author+'Player]: ************************************* NO! break')
|
||||||
break
|
break
|
||||||
except Exception, e:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
log(traceback.format_exc())
|
log(traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
|
@ -336,12 +333,6 @@ class AnteoPlayer(xbmc.Player):
|
||||||
showMessage(self.localize('Information'),
|
showMessage(self.localize('Information'),
|
||||||
self.localize('Torrent downloading is stopped.'), forced=True)
|
self.localize('Torrent downloading is stopped.'), forced=True)
|
||||||
|
|
||||||
def __exit__(self):
|
|
||||||
log('on __exit__')
|
|
||||||
if self.engine:
|
|
||||||
self.engine.close()
|
|
||||||
log('__exit__ worked!')
|
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.next_contentId = False
|
self.next_contentId = False
|
||||||
self.display_name = ''
|
self.display_name = ''
|
||||||
|
|
|
@ -32,7 +32,7 @@ import xbmcgui
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
import Localization
|
import Localization
|
||||||
from functions import isSubtitle, DownloadDB, log, debug, is_writable,\
|
from functions import isSubtitle, DownloadDB, log, debug, is_writable,\
|
||||||
vista_check, windows_check, localize_path, get_platform
|
vista_check, windows_check, localize_path
|
||||||
|
|
||||||
class Libtorrent:
|
class Libtorrent:
|
||||||
magnetLink = None
|
magnetLink = None
|
||||||
|
@ -48,7 +48,6 @@ class Libtorrent:
|
||||||
__settings__ = sys.modules["__main__"].__settings__
|
__settings__ = sys.modules["__main__"].__settings__
|
||||||
|
|
||||||
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
|
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
|
||||||
self.platform = get_platform()
|
|
||||||
self.storageDirectory = storageDirectory
|
self.storageDirectory = storageDirectory
|
||||||
self.torrentFilesPath = os.path.join(self.storageDirectory, torrentFilesDirectory) + os.sep
|
self.torrentFilesPath = os.path.join(self.storageDirectory, torrentFilesDirectory) + os.sep
|
||||||
if not is_writable(self.storageDirectory):
|
if not is_writable(self.storageDirectory):
|
||||||
|
@ -61,11 +60,11 @@ class Libtorrent:
|
||||||
try:
|
try:
|
||||||
from python_libtorrent import get_libtorrent
|
from python_libtorrent import get_libtorrent
|
||||||
libtorrent=get_libtorrent()
|
libtorrent=get_libtorrent()
|
||||||
log('Imported libtorrent v%s from python_libtorrent/%s' %(libtorrent.version, self.platform['system']))
|
log('Imported libtorrent v%s from python_libtorrent' %(libtorrent.version))
|
||||||
module=True
|
module=True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module=False
|
module=False
|
||||||
log('Error importing python_libtorrent.%s. Exception: %s' %(self.platform['system'], str(e)))
|
log('Error importing python_libtorrent Exception: %s' %( str(e)))
|
||||||
import libtorrent
|
import libtorrent
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -124,11 +123,11 @@ class Libtorrent:
|
||||||
log('Exception: ' + str(e))
|
log('Exception: ' + str(e))
|
||||||
xbmcvfs.delete(torrentFile)
|
xbmcvfs.delete(torrentFile)
|
||||||
return
|
return
|
||||||
baseName = localize_path(os.path.basename(self.getFilePath()))
|
#baseName = localize_path(os.path.basename(self.getFilePath()))
|
||||||
if not xbmcvfs.exists(self.torrentFilesPath):
|
if not xbmcvfs.exists(self.torrentFilesPath):
|
||||||
xbmcvfs.mkdirs(self.torrentFilesPath)
|
xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||||
newFile = self.torrentFilesPath + self.md5(baseName) + '.' + self.md5(
|
newFile = self.torrentFilesPath + self.md5(
|
||||||
torrentUrl) + '.torrent' # + '.'+ baseName
|
torrentUrl) + '.torrent' #self.md5(baseName) + '.' +
|
||||||
if xbmcvfs.exists(newFile):
|
if xbmcvfs.exists(newFile):
|
||||||
xbmcvfs.delete(newFile)
|
xbmcvfs.delete(newFile)
|
||||||
if not xbmcvfs.exists(newFile):
|
if not xbmcvfs.exists(newFile):
|
||||||
|
|
18
functions.py
18
functions.py
|
@ -1999,7 +1999,8 @@ def ensure_str(string, encoding='utf-8'):
|
||||||
|
|
||||||
def file_url(torrentFile):
|
def file_url(torrentFile):
|
||||||
import urlparse
|
import urlparse
|
||||||
if not re.match("^file\:.+$", torrentFile) and xbmcvfs.exists(torrentFile):
|
torrentFile = ensure_str(torrentFile)
|
||||||
|
if not re.match("^file\:.+$", torrentFile):
|
||||||
torrentFile = urlparse.urljoin('file:', urllib.pathname2url(torrentFile))
|
torrentFile = urlparse.urljoin('file:', urllib.pathname2url(torrentFile))
|
||||||
return torrentFile
|
return torrentFile
|
||||||
|
|
||||||
|
@ -2044,15 +2045,6 @@ def uri2path(uri):
|
||||||
absPath = os.path.abspath(urllib.unquote(uriPath))
|
absPath = os.path.abspath(urllib.unquote(uriPath))
|
||||||
return localize_path(absPath)
|
return localize_path(absPath)
|
||||||
|
|
||||||
def normalize_msg(tmpl, *args):
|
|
||||||
import chardet
|
|
||||||
msg = isinstance(tmpl, unicode) and tmpl or tmpl.decode(chardet.detect(tmpl)['encoding'])
|
|
||||||
arg_ = []
|
|
||||||
for a in args:
|
|
||||||
if not isinstance(a, unicode): arg_.append(a.decode(chardet.detect(a)['encoding']))
|
|
||||||
return msg % tuple(arg_)
|
|
||||||
|
|
||||||
|
|
||||||
def localize_path(path):
|
def localize_path(path):
|
||||||
import chardet
|
import chardet
|
||||||
if not isinstance(path, unicode): path = path.decode(chardet.detect(path)['encoding'])
|
if not isinstance(path, unicode): path = path.decode(chardet.detect(path)['encoding'])
|
||||||
|
@ -2060,6 +2052,12 @@ def localize_path(path):
|
||||||
path = path.encode(True and sys.getfilesystemencoding() or 'utf-8')
|
path = path.encode(True and sys.getfilesystemencoding() or 'utf-8')
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def delocalize_path(path):
|
||||||
|
import chardet
|
||||||
|
if not isinstance(path, unicode): path = path.decode(chardet.detect(path)['encoding'])
|
||||||
|
path = path.encode('utf-8')
|
||||||
|
return path
|
||||||
|
|
||||||
def get_platform():
|
def get_platform():
|
||||||
ret = {
|
ret = {
|
||||||
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
||||||
|
|
Loading…
Reference in New Issue