diff --git a/python_libtorrent/__init__.py b/python_libtorrent/__init__.py index d8ded52..c318d75 100644 --- a/python_libtorrent/__init__.py +++ b/python_libtorrent/__init__.py @@ -65,36 +65,30 @@ try: log('CDLL = ' + str(liblibtorrent)) import libtorrent elif platform['system'] in ['android_armv7', 'android_x86']: + import imp + from ctypes import CDLL try: - import libtorrent - log('Imported libtorrent v' + libtorrent.version + ' from system') - except Exception, e: - log('Error importing libtorrent from system. Exception: ' + str(e)) - - 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) + 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() + 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 + '"') diff --git a/python_libtorrent/functions.py b/python_libtorrent/functions.py index 4b05f62..a3e0c12 100644 --- a/python_libtorrent/functions.py +++ b/python_libtorrent/functions.py @@ -76,7 +76,7 @@ class LibraryManager(): return True def android_workaround(self): - new_dest_path=os.path.join(xbmc.translatePath('special://xbmc'), self.platform['system']) + new_dest_path='/data/data/org.xbmc.kodi/lib/' for libname in get_libname(self.platform): libpath=os.path.join(self.dest_path, libname) size=str(os.path.getsize(libpath))