android update
parent
cea4adbd41
commit
bd8df8776a
|
@ -1,5 +1,7 @@
|
|||
0.16.19k:
|
||||
0.16.19:
|
||||
Edit custom library path with keyboard
|
||||
Added Android permission workaround (copy to kodi path)
|
||||
Added Android system import try
|
||||
|
||||
0.6.19k:
|
||||
Added custom library path
|
||||
|
|
|
@ -26,6 +26,7 @@ __settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
|
|||
__language__ = __settings__.getLocalizedString
|
||||
if __settings__.getSetting('ask_dirname')=='true':
|
||||
set_dirname=__settings__.getSetting('dirname')
|
||||
__settings__.setSetting('ask_dirname','false')
|
||||
keyboard = xbmc.Keyboard(set_dirname, __language__(1002))
|
||||
keyboard.doModal()
|
||||
path_keyboard = keyboard.getText()
|
||||
|
|
|
@ -65,28 +65,41 @@ try:
|
|||
log('CDLL = ' + str(liblibtorrent))
|
||||
import libtorrent
|
||||
elif platform['system'] in ['android_armv7', 'android_x86']:
|
||||
import imp
|
||||
from ctypes import CDLL
|
||||
|
||||
dll_path=os.path.join(dest_path, 'liblibtorrent.so')
|
||||
log('CDLL path = ' + dll_path)
|
||||
liblibtorrent=CDLL(dll_path)
|
||||
log('CDLL = ' + str(liblibtorrent))
|
||||
|
||||
path_list = [dest_path]
|
||||
log('path_list = ' + str(path_list))
|
||||
fp, pathname, description = imp.find_module('libtorrent', path_list)
|
||||
log('fp = ' + str(fp))
|
||||
log('pathname = ' + str(pathname))
|
||||
try:
|
||||
libtorrent = imp.load_module('libtorrent', fp, pathname, description)
|
||||
finally:
|
||||
if fp: fp.close()
|
||||
import libtorrent
|
||||
log('Imported libtorrent v' + libtorrent.version + ' from system')
|
||||
except Exception, e:
|
||||
log('Error importing libtorrent from system. Exception: ' + str(e))
|
||||
|
||||
log('Imported libtorrent v' + libtorrent.version + ' from ' + dest_path)
|
||||
import imp
|
||||
from ctypes import CDLL
|
||||
try:
|
||||
dll_path=os.path.join(dest_path, 'liblibtorrent.so')
|
||||
log('CDLL path = ' + dll_path)
|
||||
liblibtorrent=CDLL(dll_path)
|
||||
log('CDLL = ' + str(liblibtorrent))
|
||||
except:
|
||||
# If no permission in dest_path we need to go deeper!
|
||||
# http://i3.kym-cdn.com/photos/images/original/000/531/557/a88.jpg
|
||||
dest_path=lm.android_workaround()
|
||||
dll_path=os.path.join(dest_path, 'liblibtorrent.so')
|
||||
log('NEW CDLL path = ' + dll_path)
|
||||
liblibtorrent=CDLL(dll_path)
|
||||
log('CDLL = ' + str(liblibtorrent))
|
||||
path_list = [dest_path]
|
||||
log('path_list = ' + str(path_list))
|
||||
fp, pathname, description = imp.find_module('libtorrent', path_list)
|
||||
log('fp = ' + str(fp))
|
||||
log('pathname = ' + str(pathname))
|
||||
try:
|
||||
libtorrent = imp.load_module('libtorrent', fp, pathname, description)
|
||||
finally:
|
||||
if fp: fp.close()
|
||||
|
||||
log('Imported libtorrent v' + libtorrent.version + ' from "' + dest_path + '"')
|
||||
|
||||
except Exception, e:
|
||||
log('Error importing libtorrent from' + dest_path + '. Exception: ' + str(e))
|
||||
log('Error importing libtorrent from "' + dest_path + '". Exception: ' + str(e))
|
||||
pass
|
||||
|
||||
def get_libtorrent():
|
||||
|
|
|
@ -13,31 +13,6 @@ __language__ = __settings__.getLocalizedString
|
|||
|
||||
from platform_pulsar import get_platform, get_libname
|
||||
|
||||
class DownloaderClass():
|
||||
def __init__(self, dest_path):
|
||||
self.dest_path = dest_path
|
||||
self.platform = get_platform()
|
||||
tempdir(self.dest_path)
|
||||
|
||||
def tools_download(self):
|
||||
for libname in get_libname(self.platform):
|
||||
dest = os.path.join(self.dest_path, libname)
|
||||
log("try to fetch %s" % libname)
|
||||
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform['system'], libname)
|
||||
if libname!='liblibtorrent.so':
|
||||
try:
|
||||
self.http = HTTP()
|
||||
self.http.fetch(url, download=dest + ".zip", progress=True)
|
||||
log("%s -> %s" % (url, dest))
|
||||
xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path), True)
|
||||
xbmcvfs.delete(dest + ".zip")
|
||||
except:
|
||||
text = 'Failed download %s!' % libname
|
||||
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__plugin__,text,750,__icon__))
|
||||
else:
|
||||
x=xbmcvfs.copy(os.path.join(self.dest_path, 'libtorrent.so'), dest)
|
||||
return True
|
||||
|
||||
def log(msg):
|
||||
try:
|
||||
xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=xbmc.LOGNOTICE )
|
||||
|
@ -46,10 +21,6 @@ def log(msg):
|
|||
except:
|
||||
xbmc.log("### [%s]: %s" % (__plugin__,'ERROR LOG',), level=xbmc.LOGNOTICE )
|
||||
|
||||
def tempdir(dirname):
|
||||
xbmcvfs.mkdirs(dirname)
|
||||
return dirname
|
||||
|
||||
def getSettingAsBool(setting):
|
||||
return __settings__.getSetting(setting).lower() == "true"
|
||||
|
||||
|
@ -85,4 +56,39 @@ class LibraryManager():
|
|||
self.download()
|
||||
|
||||
def download(self):
|
||||
DownloaderClass(self.dest_path).tools_download()
|
||||
xbmcvfs.mkdirs(self.dest_path)
|
||||
for libname in get_libname(self.platform):
|
||||
dest = os.path.join(self.dest_path, libname)
|
||||
log("try to fetch %s" % libname)
|
||||
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform['system'], libname)
|
||||
if libname!='liblibtorrent.so':
|
||||
try:
|
||||
self.http = HTTP()
|
||||
self.http.fetch(url, download=dest + ".zip", progress=True)
|
||||
log("%s -> %s" % (url, dest))
|
||||
xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path), True)
|
||||
xbmcvfs.delete(dest + ".zip")
|
||||
except:
|
||||
text = 'Failed download %s!' % libname
|
||||
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__plugin__,text,750,__icon__))
|
||||
else:
|
||||
xbmcvfs.copy(os.path.join(self.dest_path, 'libtorrent.so'), dest)
|
||||
return True
|
||||
|
||||
def android_workaround(self):
|
||||
new_dest_path=os.path.join(xbmc.translatePath('special://xbmc'), self.platform['system'])
|
||||
for libname in get_libname(self.platform):
|
||||
libpath=os.path.join(self.dest_path, libname)
|
||||
size=str(os.path.getsize(libpath))
|
||||
new_libpath=os.path.join(new_dest_path, libname)
|
||||
|
||||
if not xbmcvfs.exists(new_libpath):
|
||||
xbmcvfs.copy(libpath, new_libpath)
|
||||
log('Copied %s -> %s' %(libpath, new_libpath))
|
||||
else:
|
||||
new_size=str(os.path.getsize(new_libpath))
|
||||
if size!=new_size:
|
||||
xbmcvfs.delete(new_libpath)
|
||||
xbmcvfs.copy(libpath, new_libpath)
|
||||
log('Deleted and copied (%s) %s -> (%s) %s' %(size, libpath, new_size, new_libpath))
|
||||
return new_dest_path
|
||||
|
|
Loading…
Reference in New Issue