rus fixes
parent
5879013616
commit
09bb692650
|
@ -117,12 +117,6 @@ class AnteoLoader:
|
|||
else:
|
||||
self.torrentFile = torrentFile
|
||||
|
||||
def __exit__(self):
|
||||
log('on __exit__')
|
||||
if self.engine:
|
||||
self.engine.close()
|
||||
log('__exit__ worked!')
|
||||
|
||||
def setup_engine(self):
|
||||
encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED
|
||||
|
||||
|
@ -163,13 +157,15 @@ class AnteoLoader:
|
|||
torrent = Libtorrent(self.storageDirectory, self.torrentFile)
|
||||
return torrent.getContentList()
|
||||
except:
|
||||
import traceback
|
||||
log(traceback.format_exc())
|
||||
return self.getContentList_engine()
|
||||
|
||||
def getContentList_engine(self):
|
||||
self.setup_engine()
|
||||
files = []
|
||||
filelist = []
|
||||
with closing(self.engine):
|
||||
try:
|
||||
self.engine.start()
|
||||
#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,
|
||||
'offset': fs.offset}
|
||||
filelist.append(stringdata)
|
||||
except:
|
||||
import traceback
|
||||
log(traceback.format_exc())
|
||||
finally:
|
||||
self.engine.close()
|
||||
return filelist
|
||||
|
||||
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' %
|
||||
(torrentUrl, torrentFile, str(e)))
|
||||
return
|
||||
#else:
|
||||
#torrentFile = torrentUrl
|
||||
if xbmcvfs.exists(torrentFile) and not os.path.exists(torrentFile):
|
||||
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
|
||||
|
@ -287,10 +286,8 @@ class AnteoPlayer(xbmc.Player):
|
|||
self.contentId = int(self.get("url"))
|
||||
if self.get("seek"):
|
||||
self.seek = int(self.get("seek"))
|
||||
#self.torrent = AnteoLoader(self.userStorageDirectory, self.torrentUrl, self.torrentFilesDirectory)
|
||||
self.init()
|
||||
self.setup_engine()
|
||||
#with closing(self.engine):
|
||||
try:
|
||||
self.engine.start(self.contentId)
|
||||
self.setup_nextep()
|
||||
|
@ -316,7 +313,7 @@ class AnteoPlayer(xbmc.Player):
|
|||
continue
|
||||
log('['+author+'Player]: ************************************* NO! break')
|
||||
break
|
||||
except Exception, e:
|
||||
except:
|
||||
import traceback
|
||||
log(traceback.format_exc())
|
||||
finally:
|
||||
|
@ -336,12 +333,6 @@ class AnteoPlayer(xbmc.Player):
|
|||
showMessage(self.localize('Information'),
|
||||
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):
|
||||
self.next_contentId = False
|
||||
self.display_name = ''
|
||||
|
|
|
@ -32,7 +32,7 @@ import xbmcgui
|
|||
import xbmcvfs
|
||||
import Localization
|
||||
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:
|
||||
magnetLink = None
|
||||
|
@ -48,7 +48,6 @@ class Libtorrent:
|
|||
__settings__ = sys.modules["__main__"].__settings__
|
||||
|
||||
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
|
||||
self.platform = get_platform()
|
||||
self.storageDirectory = storageDirectory
|
||||
self.torrentFilesPath = os.path.join(self.storageDirectory, torrentFilesDirectory) + os.sep
|
||||
if not is_writable(self.storageDirectory):
|
||||
|
@ -61,11 +60,11 @@ class Libtorrent:
|
|||
try:
|
||||
from python_libtorrent import 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
|
||||
except Exception, e:
|
||||
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
|
||||
|
||||
try:
|
||||
|
@ -124,11 +123,11 @@ class Libtorrent:
|
|||
log('Exception: ' + str(e))
|
||||
xbmcvfs.delete(torrentFile)
|
||||
return
|
||||
baseName = localize_path(os.path.basename(self.getFilePath()))
|
||||
#baseName = localize_path(os.path.basename(self.getFilePath()))
|
||||
if not xbmcvfs.exists(self.torrentFilesPath):
|
||||
xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||
newFile = self.torrentFilesPath + self.md5(baseName) + '.' + self.md5(
|
||||
torrentUrl) + '.torrent' # + '.'+ baseName
|
||||
newFile = self.torrentFilesPath + self.md5(
|
||||
torrentUrl) + '.torrent' #self.md5(baseName) + '.' +
|
||||
if xbmcvfs.exists(newFile):
|
||||
xbmcvfs.delete(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):
|
||||
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))
|
||||
return torrentFile
|
||||
|
||||
|
@ -2044,15 +2045,6 @@ def uri2path(uri):
|
|||
absPath = os.path.abspath(urllib.unquote(uriPath))
|
||||
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):
|
||||
import chardet
|
||||
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')
|
||||
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():
|
||||
ret = {
|
||||
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
||||
|
|
Loading…
Reference in New Issue