android update
This commit is contained in:
parent
495c0377cd
commit
37a5a73964
17
README.md
Normal file
17
README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Python-Libtorrent for Kodi
|
||||||
|
==================
|
||||||
|
script.module.libtorrent is a Kodi module that makes easy import of python-libtorrent for you. Example of usage is Torrenter v2 at https://github.com/DiMartinoXBMC/plugin.video.torrenter
|
||||||
|
|
||||||
|
- Forum: http://forum.kodi.tv/showthread.php?tid=214366
|
||||||
|
|
||||||
|
Usage
|
||||||
|
==================
|
||||||
|
|
||||||
|
#. Add module in requires of your addon.xml:
|
||||||
|
|
||||||
|
* <import addon="script.module.libtorrent"/>
|
||||||
|
|
||||||
|
#. Use it in any python file:
|
||||||
|
|
||||||
|
* from python_libtorrent import get_libtorrent
|
||||||
|
* libtorrent=get_libtorrent()
|
@ -1,2 +1,6 @@
|
|||||||
0.6.10b:
|
0.6.19b:
|
||||||
|
Added windows 0.16.19, OS X 0.16.19, Android ARM 0.16.19
|
||||||
|
Automatic download system
|
||||||
|
|
||||||
|
0.6.10b:
|
||||||
Windows update to 0.6.18
|
Windows update to 0.6.18
|
@ -12,8 +12,8 @@ import os
|
|||||||
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
|
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
|
||||||
__version__ = __settings__.getAddonInfo('version')
|
__version__ = __settings__.getAddonInfo('version')
|
||||||
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
|
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
|
||||||
__root__ = __settings__.getAddonInfo('path')
|
|
||||||
|
|
||||||
|
libtorrent=None
|
||||||
platform = get_platform()
|
platform = get_platform()
|
||||||
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
|
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
|
||||||
'python_libtorrent')
|
'python_libtorrent')
|
||||||
@ -24,7 +24,8 @@ sys.path.insert(0, dest_path)
|
|||||||
|
|
||||||
lm=LibraryManager(dest_path)
|
lm=LibraryManager(dest_path)
|
||||||
if not lm.check_exist():
|
if not lm.check_exist():
|
||||||
DownloaderClass(dest_path).tools_download()
|
ok=lm.download()
|
||||||
|
xbmc.sleep(2000)
|
||||||
|
|
||||||
|
|
||||||
if __settings__.getSetting('plugin_name')!=__plugin__:
|
if __settings__.getSetting('plugin_name')!=__plugin__:
|
||||||
@ -35,7 +36,7 @@ log('platform ' + str(platform))
|
|||||||
try:
|
try:
|
||||||
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64', 'windows']:
|
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64', 'windows']:
|
||||||
import libtorrent
|
import libtorrent
|
||||||
elif platform['system'] == 'android' and platform['arch'] == 'arm':
|
elif platform['system'] == 'android_armv7':
|
||||||
import imp
|
import imp
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
69205188
|
|
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
69205188
|
|
Binary file not shown.
1
python_libtorrent/android_armv7/libtorrent.so.size.txt
Normal file
1
python_libtorrent/android_armv7/libtorrent.so.size.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
6804840
|
BIN
python_libtorrent/android_armv7/libtorrent.so.zip
Normal file
BIN
python_libtorrent/android_armv7/libtorrent.so.zip
Normal file
Binary file not shown.
Binary file not shown.
@ -1,6 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import xbmc, xbmcgui, xbmcvfs
|
try:
|
||||||
|
import xbmc, xbmcgui, xbmcvfs
|
||||||
|
except:
|
||||||
|
pass
|
||||||
from net import HTTP
|
from net import HTTP
|
||||||
|
|
||||||
__libbaseurl__ = "https://github.com/DiMartinoXBMC/script.module.libtorrent/raw/master/python_libtorrent/"
|
__libbaseurl__ = "https://github.com/DiMartinoXBMC/script.module.libtorrent/raw/master/python_libtorrent/"
|
||||||
@ -16,18 +19,22 @@ class DownloaderClass():
|
|||||||
|
|
||||||
def tools_download(self):
|
def tools_download(self):
|
||||||
for libname in get_libname(self.platform):
|
for libname in get_libname(self.platform):
|
||||||
|
dest = os.path.join(self.dest_path, libname)
|
||||||
log("try to fetch %s" % libname)
|
log("try to fetch %s" % libname)
|
||||||
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform['system'], libname)
|
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform['system'], libname)
|
||||||
dest = os.path.join(self.dest_path, libname)
|
if libname!='liblibtorrent.so':
|
||||||
try:
|
try:
|
||||||
self.http = HTTP()
|
self.http = HTTP()
|
||||||
self.http.fetch(url, download=dest + ".zip", progress=True)
|
self.http.fetch(url, download=dest + ".zip", progress=True)
|
||||||
log("%s -> %s" % (url, dest))
|
log("%s -> %s" % (url, dest))
|
||||||
xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path), True)
|
xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path), True)
|
||||||
xbmcvfs.delete(dest + ".zip")
|
xbmcvfs.delete(dest + ".zip")
|
||||||
except:
|
except:
|
||||||
text = 'Failed!'
|
text = 'Failed download %s!' % libname
|
||||||
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,text,750,__icon__))
|
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,text,750,__icon__))
|
||||||
|
else:
|
||||||
|
x=xbmcvfs.copy(os.path.join(self.dest_path, 'libtorrent.so', dest))
|
||||||
|
return True
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
xbmc.log("### [%s]: %s" % (__scriptname__,msg,), level=xbmc.LOGNOTICE )
|
xbmc.log("### [%s]: %s" % (__scriptname__,msg,), level=xbmc.LOGNOTICE )
|
||||||
@ -35,15 +42,11 @@ def log(msg):
|
|||||||
|
|
||||||
def get_libname(platform):
|
def get_libname(platform):
|
||||||
libname=[]
|
libname=[]
|
||||||
if platform['system'] == 'darwin':
|
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64']:
|
||||||
libname=['libtorrent.so']
|
|
||||||
elif platform['system'] == 'linux_x86':
|
|
||||||
libname=['libtorrent.so']
|
|
||||||
elif platform['system'] == 'linux_x86_64':
|
|
||||||
libname=['libtorrent.so']
|
libname=['libtorrent.so']
|
||||||
elif platform['system'] == 'windows':
|
elif platform['system'] == 'windows':
|
||||||
libname=['libtorrent.pyd']
|
libname=['libtorrent.pyd']
|
||||||
elif platform['system'] == 'android' and platform['arch'] == 'arm':
|
elif platform['system'] == 'android_armv7':
|
||||||
libname=['libtorrent.so', 'liblibtorrent.so']
|
libname=['libtorrent.so', 'liblibtorrent.so']
|
||||||
return libname
|
return libname
|
||||||
|
|
||||||
@ -90,16 +93,19 @@ def get_platform():
|
|||||||
ret["message"] = ['As far as I know you can compile python-libtorrent for ARMv6-7.',
|
ret["message"] = ['As far as I know you can compile python-libtorrent for ARMv6-7.',
|
||||||
'You should search for "OneEvil\'s OpenELEC libtorrent" or use Ace Stream.']
|
'You should search for "OneEvil\'s OpenELEC libtorrent" or use Ace Stream.']
|
||||||
elif ret["os"] == "android":
|
elif ret["os"] == "android":
|
||||||
ret["system"] = 'android'
|
if ret["arch"]=='arm':
|
||||||
ret["message"] = ['Please use install Ace Stream APK and choose it in Settings.',
|
ret["system"] = 'android_armv7'
|
||||||
'It is possible to compile python-libtorrent for Android, but I don\'t know how.']
|
else:
|
||||||
|
ret["system"] = 'android_x86'
|
||||||
|
ret["message"] = ['Please contact DiMartino on kodi.tv forum. We compiled python-libtorrent for Android,',
|
||||||
|
'but we need your help with some tests on diffrient processeors.']
|
||||||
elif ret["os"] == "darwin":
|
elif ret["os"] == "darwin":
|
||||||
ret["system"] = 'darwin'
|
ret["system"] = 'darwin'
|
||||||
ret["message"] = ['It is possible to compile python-libtorrent for OS X.',
|
ret["message"] = ['It is possible to compile python-libtorrent for OS X.',
|
||||||
'But you would have to do it by yourself, there is some info on github.com.']
|
'But you would have to do it by yourself, there is some info on github.com.']
|
||||||
elif ret["os"] == "ios":
|
elif ret["os"] == "ios":
|
||||||
ret["system"] = 'ios'
|
ret["system"] = 'ios'
|
||||||
ret["message"] = ['It is NOT possible to compile python-libtorrent for iOS.',
|
ret["message"] = ['It is probably NOT possible to compile python-libtorrent for iOS.',
|
||||||
'But you can use torrent-client control functions.']
|
'But you can use torrent-client control functions.']
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -116,6 +122,7 @@ class LibraryManager():
|
|||||||
def __init__(self, dest_path):
|
def __init__(self, dest_path):
|
||||||
self.dest_path = dest_path
|
self.dest_path = dest_path
|
||||||
self.platform = get_platform()
|
self.platform = get_platform()
|
||||||
|
self.root=os.path.dirname(__file__)
|
||||||
|
|
||||||
def check_exist(self):
|
def check_exist(self):
|
||||||
for libname in get_libname(self.platform):
|
for libname in get_libname(self.platform):
|
||||||
@ -124,9 +131,23 @@ class LibraryManager():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def check_update(self):
|
def check_update(self):
|
||||||
return False
|
need_update=False
|
||||||
|
for libname in get_libname(self.platform):
|
||||||
|
if libname!='liblibtorrent.so':
|
||||||
|
self.libpath = os.path.join(self.dest_path, libname)
|
||||||
|
self.sizepath=os.path.join(self.root, self.platform['system'], libname+'.size.txt')
|
||||||
|
size=str(os.path.getsize(self.libpath))
|
||||||
|
size_old=open( self.sizepath, "r" ).read()
|
||||||
|
if size_old!=size:
|
||||||
|
need_update=True
|
||||||
|
return need_update
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.check_update():
|
if self.check_update():
|
||||||
#DO UPDATE
|
for libname in get_libname(self.platform):
|
||||||
pass
|
self.libpath = os.path.join(self.dest_path, libname)
|
||||||
|
xbmcvfs.delete(self.libpath)
|
||||||
|
self.download()
|
||||||
|
|
||||||
|
def download(self):
|
||||||
|
DownloaderClass(self.dest_path).tools_download()
|
Binary file not shown.
@ -6,28 +6,24 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
#UPDATE IT FROM functions
|
||||||
def get_libname(platform):
|
def get_libname(platform):
|
||||||
libname=[]
|
libname=[]
|
||||||
if platform['system'] == 'darwin':
|
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64']:
|
||||||
libname=['libtorrent.so']
|
|
||||||
elif platform['system'] == 'linux_x86':
|
|
||||||
libname=['libtorrent.so']
|
|
||||||
elif platform['system'] == 'linux_x86_64':
|
|
||||||
libname=['libtorrent.so']
|
libname=['libtorrent.so']
|
||||||
elif platform['system'] == 'windows':
|
elif platform['system'] == 'windows':
|
||||||
libname=['libtorrent.pyd']
|
libname=['libtorrent.pyd']
|
||||||
elif platform['system'] == 'android' and platform['arch'] == 'arm':
|
elif platform['system'] == 'android_armv7':
|
||||||
libname=['libtorrent.so', 'liblibtorrent.so']
|
libname=['libtorrent.so', 'liblibtorrent.so']
|
||||||
return libname
|
return libname
|
||||||
|
|
||||||
class Public:
|
class Public:
|
||||||
def __init__( self ):
|
def __init__( self ):
|
||||||
# generate file
|
|
||||||
self.platforms=[{'system':'darwin'},
|
self.platforms=[{'system':'darwin'},
|
||||||
{'system':'linux_x86'},
|
{'system':'linux_x86'},
|
||||||
{'system':'linux_x86_64'},
|
{'system':'linux_x86_64'},
|
||||||
{'system':'windows'},
|
{'system':'windows'},
|
||||||
{'system':'android', 'arch':'arm'}]
|
{'system':'android_armv7'}]
|
||||||
self.root=os.path.dirname(__file__)
|
self.root=os.path.dirname(__file__)
|
||||||
self._generate_size_file()
|
self._generate_size_file()
|
||||||
|
|
||||||
@ -71,4 +67,5 @@ class Public:
|
|||||||
|
|
||||||
if ( __name__ == "__main__" ):
|
if ( __name__ == "__main__" ):
|
||||||
# start
|
# start
|
||||||
|
#TODO: publicate
|
||||||
Public()
|
Public()
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user