android update

pull/1/head
DiMartinoXBMC 2015-07-11 23:49:53 +03:00
parent 495c0377cd
commit 37a5a73964
17 changed files with 77 additions and 38 deletions

17
README.md 100644
View 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()

View File

@ -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

View File

@ -12,8 +12,8 @@ import os
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
__version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__root__ = __settings__.getAddonInfo('path')
libtorrent=None
platform = get_platform()
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
'python_libtorrent')
@ -24,7 +24,8 @@ sys.path.insert(0, dest_path)
lm=LibraryManager(dest_path)
if not lm.check_exist():
DownloaderClass(dest_path).tools_download()
ok=lm.download()
xbmc.sleep(2000)
if __settings__.getSetting('plugin_name')!=__plugin__:
@ -35,7 +36,7 @@ log('platform ' + str(platform))
try:
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64', 'windows']:
import libtorrent
elif platform['system'] == 'android' and platform['arch'] == 'arm':
elif platform['system'] == 'android_armv7':
import imp
from ctypes import *

View File

@ -1 +0,0 @@
69205188

View File

@ -1 +0,0 @@
69205188

View File

@ -0,0 +1 @@
6804840

View File

@ -1,6 +1,9 @@
import sys
import os
import xbmc, xbmcgui, xbmcvfs
try:
import xbmc, xbmcgui, xbmcvfs
except:
pass
from net import HTTP
__libbaseurl__ = "https://github.com/DiMartinoXBMC/script.module.libtorrent/raw/master/python_libtorrent/"
@ -16,18 +19,22 @@ class DownloaderClass():
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)
dest = os.path.join(self.dest_path, libname)
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!'
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,text,750,__icon__))
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)" % (__scriptname__,text,750,__icon__))
else:
x=xbmcvfs.copy(os.path.join(self.dest_path, 'libtorrent.so', dest))
return True
def log(msg):
xbmc.log("### [%s]: %s" % (__scriptname__,msg,), level=xbmc.LOGNOTICE )
@ -35,15 +42,11 @@ def log(msg):
def get_libname(platform):
libname=[]
if platform['system'] == 'darwin':
libname=['libtorrent.so']
elif platform['system'] == 'linux_x86':
libname=['libtorrent.so']
elif platform['system'] == 'linux_x86_64':
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64']:
libname=['libtorrent.so']
elif platform['system'] == 'windows':
libname=['libtorrent.pyd']
elif platform['system'] == 'android' and platform['arch'] == 'arm':
elif platform['system'] == 'android_armv7':
libname=['libtorrent.so', 'liblibtorrent.so']
return libname
@ -90,16 +93,19 @@ def get_platform():
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.']
elif ret["os"] == "android":
ret["system"] = 'android'
ret["message"] = ['Please use install Ace Stream APK and choose it in Settings.',
'It is possible to compile python-libtorrent for Android, but I don\'t know how.']
if ret["arch"]=='arm':
ret["system"] = 'android_armv7'
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":
ret["system"] = 'darwin'
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.']
elif ret["os"] == "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.']
return ret
@ -116,6 +122,7 @@ class LibraryManager():
def __init__(self, dest_path):
self.dest_path = dest_path
self.platform = get_platform()
self.root=os.path.dirname(__file__)
def check_exist(self):
for libname in get_libname(self.platform):
@ -124,9 +131,23 @@ class LibraryManager():
return True
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):
if self.check_update():
#DO UPDATE
pass
for libname in get_libname(self.platform):
self.libpath = os.path.join(self.dest_path, libname)
xbmcvfs.delete(self.libpath)
self.download()
def download(self):
DownloaderClass(self.dest_path).tools_download()

View File

@ -6,28 +6,24 @@
import os
#UPDATE IT FROM functions
def get_libname(platform):
libname=[]
if platform['system'] == 'darwin':
libname=['libtorrent.so']
elif platform['system'] == 'linux_x86':
libname=['libtorrent.so']
elif platform['system'] == 'linux_x86_64':
if platform['system'] in ['darwin', 'linux_x86', 'linux_x86_64']:
libname=['libtorrent.so']
elif platform['system'] == 'windows':
libname=['libtorrent.pyd']
elif platform['system'] == 'android' and platform['arch'] == 'arm':
elif platform['system'] == 'android_armv7':
libname=['libtorrent.so', 'liblibtorrent.so']
return libname
class Public:
def __init__( self ):
# generate file
self.platforms=[{'system':'darwin'},
{'system':'linux_x86'},
{'system':'linux_x86_64'},
{'system':'windows'},
{'system':'android', 'arch':'arm'}]
{'system':'android_armv7'}]
self.root=os.path.dirname(__file__)
self._generate_size_file()
@ -71,4 +67,5 @@ class Public:
if ( __name__ == "__main__" ):
# start
#TODO: publicate
Public()