adnroid update

pull/1/head
DiMartinoXBMC 2015-07-11 12:00:55 +03:00
parent 70d01a0043
commit bfb3c289dd
25 changed files with 337 additions and 144 deletions

View File

@ -1,15 +1,14 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<addon id='script.module.libtorrent' version='0.6.19' name='LibTorrent' provider-name='DiMartino'>
<addon id='script.module.libtorrent' version='0.6.19b' name='LibTorrent' provider-name='DiMartino'>
<requires>
<import addon='xbmc.python' version='2.1.0'/>
</requires>
<extension point="xbmc.python.script" library="__init__.py">
<extension point="xbmc.python.script" library="default.py">
<provides>executable</provides>
</extension>
<extension point='xbmc.addon.metadata'>
<platform>all</platform>
<summary>LibTorrent</summary>
</extension>
<extension library="default.py" point="xbmc.service" />
<extension point='xbmc.python.module'/>
</addon>

40
default.py 100644
View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import xbmcplugin, xbmcgui, os
from python_libtorrent.platform_pulsar import get_platform
from ctypes import *
sucsess=False
dialog = xbmcgui.Dialog()
p=get_platform()
ROOT_PATH=os.path.dirname(__file__)
dirname=os.path.join(ROOT_PATH, 'python_libtorrent', p['system'])
#dirname = os.path.join(xbmc.translatePath('special://home'), 'addons', 'script.module.libtorrent',
# 'python_libtorrent', platform['system'])
#sys.path.insert(0, dirname)
try:
import python_libtorrent as libtorrent
print '[script.module.libtorrent]: Imported libtorrent v' + libtorrent.version + ' from python_libtorrent'
sucsess=True
except Exception, e:
print '[script.module.libtorrent]: Error importing from system. Exception: ' + str(e)
try:
cdll.LoadLibrary(dirname + '/libpython2.6.so')
except Exception, e:
print '[script.module.libtorrent]: Error importing from '+str(dirname)+'. Exception: ' + str(e)
try:
cdll.LoadLibrary(dirname + '/libpython2.6.so')
cdll.LoadLibrary(dirname + '/libtorrent.so')
print '[script.module.libtorrent]: Imported libtorrent v' + libtorrent.version + ' from cdll'
sucsess=True
except Exception, e:
print '[script.module.libtorrent]: Error importing from '+str(dirname)+'. Exception: ' + str(e)
line2='WE DID IT! IMPORTED' if sucsess else 'Failed!'
dialog.ok('Libtorrent','OS:'+p['os']+' arch:'+p['arch'], line2)

View File

@ -1,30 +1,68 @@
#-*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2012-2015 Vadim Skorba - DiMartino
Copyright (C) 2015 srg70, RussakHH, DiMartino
'''
from platform_pulsar import get_platform
from functions import *
import xbmc, xbmcgui, xbmcvfs, xbmcaddon
import sys
import os
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
__version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__root__ = __settings__.getAddonInfo('path')
platform = get_platform()
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
'python_libtorrent')
#dirname = os.path.join(xbmc.translatePath('special://home'), 'addons', 'script.module.libtorrent',
# 'python_libtorrent')
dest_path = os.path.join(dirname, platform['system'])
sys.path.insert(0, dirname)
print '[script.module.libtorrent]: platform ' + str(platform)
lm=LibraryManager(dest_path)
if not lm.check_exist():
DownloaderClass(dest_path).tools_download()
if __settings__.getSetting('plugin_name')!=__plugin__:
__settings__.setSetting('plugin_name', __plugin__)
lm.update()
log('platform ' + str(platform))
try:
#dirname = os.path.join(xbmc.translatePath('special://home'), 'addons', 'script.module.libtorrent',
# 'python_libtorrent', platform['system'])
#sys.path.insert(0, dirname)
if platform['system'] == 'darwin':
from darwin.libtorrent import *
from darwin import libtorrent
elif platform['system'] == 'linux_x86':
from linux_x86.libtorrent import *
from linux_x86 import libtorrent
elif platform['system'] == 'linux_x86_64':
from linux_x86_64.libtorrent import *
from linux_x86_64 import libtorrent
elif platform['system'] == 'windows':
from windows.libtorrent import *
from windows import libtorrent
elif platform['system'] == 'android' and platform['arch'] == 'arm':
import imp
from ctypes import *
dll_path=os.path.join(dest_path, 'liblibtorrent.so')
print "CDLL path = " + dll_path
liblibtorrent=CDLL(dll_path)
print 'CDLL = ' + str(liblibtorrent)
path_list = [dest_path]
print 'path_list = ' + str(path_list)
fp, pathname, description = imp.find_module('libtorrent', path_list)
print 'fp = ' + str(fp)
print 'pathname = ' + str(pathname)
libtorrent = imp.load_module('libtorrent', fp, pathname, description)
print '[script.module.libtorrent]: Imported libtorrent v' + libtorrent.version + ' from python_libtorrent.' + platform[
'system']
#print '[script.module.libtorrent]: Imported libtorrent v' + libtorrent.version + ' from python_libtorrent.' + platform[
# 'system']
except Exception, e:
print '[script.module.libtorrent]: Error importing python_libtorrent.' + platform['system'] + '. Exception: ' + str(e)
pass
pass
def get_libtorrent():
return libtorrent

View File

@ -0,0 +1,5 @@
#-*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 srg70, RussakHH, DiMartino
'''

Binary file not shown.

View File

@ -0,0 +1 @@
69205188

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
69205188

Binary file not shown.

View File

@ -1,19 +1,5 @@
#-*- coding: utf-8 -*-
'''
Torrenter plugin for XBMC
Copyright (C) 2012 Vadim Skorba
vadim.skorba@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 DiMartino
'''

View File

@ -0,0 +1 @@
10425648

Binary file not shown.

View File

@ -0,0 +1,150 @@
import sys
import os
import xbmc, xbmcgui, xbmcvfs
import urllib
__libbaseurl__ = "https://github.com/DiMartinoXBMC/script.module.libtorrent/raw/master/python_libtorrent/"
__scriptname__ = "script.module.libtorrent"
__icon__=os.path.join(xbmc.translatePath('special://home'), 'addons',
'script.module.libtorrent', 'icon.png')
class DownloaderClass():
def __init__(self, dest_path):
self.dest_path = dest_path
self.platform = get_platform()
tempdir(self.platform)
def download(self, url, dest):
self.dp = xbmcgui.DialogProgress()
self.dp.create("script.module.libtorrent","Downloading File", url)
urllib.urlretrieve(url, dest, lambda nb, bs, fs, url= url: self._pbhook(nb,bs,fs))
def _pbhook(self, numblocks, blocksize, filesize):
try:
percent = min((numblocks*blocksize*100)/filesize, 100)
self.dp.update(percent)
except:
percent = 100
self.dp.update(percent)
log("libtorrent: DOWNLOAD FAILED")
if self.dp.iscanceled():
log("libtorrent: DOWNLOAD CANCELLED")
self.dp.close()
def tools_download(self):
log("libtorrent: try to fetch libtorrent.so")
for libname in get_libname(self.platform):
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform, libname)
dest = os.path.join(self.dest_path, libname)
try:
self.download(url, dest + ".zip")
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__))
def log(msg):
xbmc.log("### [%s]: %s" % (__scriptname__,msg,), level=xbmc.LOGINFO )
#print "### [%s]: %s" % (__scriptname__,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':
libname=['libtorrent.so']
elif platform['system'] == 'windows':
libname=['libtorrent.pyd']
elif platform['system'] == 'android' and platform['arch'] == 'arm':
libname=['libtorrent.so', 'liblibtorrent.so']
return libname
def get_platform():
ret = {
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
}
if xbmc.getCondVisibility("system.platform.android"):
ret["os"] = "android"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.linux"):
ret["os"] = "linux"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.xbox"):
system_platform = "xbox"
ret["arch"] = ""
elif xbmc.getCondVisibility("system.platform.windows"):
ret["os"] = "windows"
elif xbmc.getCondVisibility("system.platform.osx"):
ret["os"] = "darwin"
elif xbmc.getCondVisibility("system.platform.ios"):
ret["os"] = "ios"
ret["arch"] = "arm"
ret["system"] = ''
ret["message"] = ['', '']
if ret["os"] == 'windows':
ret["system"] = 'windows'
ret["message"] = ['Windows has static compiled python-libtorrent included.',
'You should install "script.module.libtorrent" from "MyShows.me Kodi Repo"']
elif ret["os"] == "linux" and ret["arch"] == "x64":
ret["system"] = 'linux_x86_64'
ret["message"] = ['Linux x64 has not static compiled python-libtorrent included.',
'You should install it by "sudo apt-get install python-libtorrent"']
elif ret["os"] == "linux" and ret["arch"] == "x86":
ret["system"] = 'linux_x86'
ret["message"] = ['Linux has static compiled python-libtorrent included but it didn\'t work.',
'You should install it by "sudo apt-get install python-libtorrent"']
elif ret["os"] == "linux" and ret["arch"] == "arm":
ret["system"] = 'linux_arm'
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.']
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.',
'But you can use torrent-client control functions.']
return ret
def tempdir(platform):
dirname=xbmc.translatePath('special://temp')
for subdir in ('xbmcup', 'script.module.libtorrent', 'python_libtorrent', platform['system']):
dirname = os.path.join(dirname, subdir)
if not xbmcvfs.exists(dirname):
xbmcvfs.mkdir(dirname)
return dirname
class LibraryManager():
def __init__(self, dest_path):
self.dest_path = dest_path
self.platform = get_platform()
def check_exist(self):
for libname in get_libname(self.platform):
if not xbmcvfs.exists(os.path.join(self.dest_path,libname)):
return False
return True
def check_update(self):
return False
def update(self):
if self.check_update():
#DO UPDATE
pass

Binary file not shown.

Binary file not shown.

View File

@ -1,19 +1,5 @@
#-*- coding: utf-8 -*-
'''
Torrenter plugin for XBMC
Copyright (C) 2012 Vadim Skorba
vadim.skorba@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 DiMartino
'''

View File

@ -0,0 +1 @@
6219339

Binary file not shown.

View File

@ -1,19 +1,5 @@
#-*- coding: utf-8 -*-
'''
Torrenter plugin for XBMC
Copyright (C) 2012 Vadim Skorba
vadim.skorba@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 DiMartino
'''

View File

@ -1,62 +0,0 @@
import sys
import os
import xbmc
def get_platform():
ret = {
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
}
if xbmc.getCondVisibility("system.platform.android"):
ret["os"] = "android"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.linux"):
ret["os"] = "linux"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.xbox"):
system_platform = "xbox"
ret["arch"] = ""
elif xbmc.getCondVisibility("system.platform.windows"):
ret["os"] = "windows"
elif xbmc.getCondVisibility("system.platform.osx"):
ret["os"] = "darwin"
elif xbmc.getCondVisibility("system.platform.ios"):
ret["os"] = "ios"
ret["arch"] = "arm"
ret["system"] = ''
ret["message"] = ['', '']
if ret["os"] == 'windows':
ret["system"] = 'windows'
ret["message"] = ['Windows has static compiled python-libtorrent included.',
'You should install "script.module.libtorrent" from "MyShows.me Kodi Repo"']
elif ret["os"] == "linux" and ret["arch"] == "x64":
ret["system"] = 'linux_x86_64'
ret["message"] = ['Linux x64 has not static compiled python-libtorrent included.',
'You should install it by "sudo apt-get install python-libtorrent"']
elif ret["os"] == "linux" and ret["arch"] == "x86":
ret["system"] = 'linux_x86'
ret["message"] = ['Linux has static compiled python-libtorrent included but it didn\'t work.',
'You should install it by "sudo apt-get install python-libtorrent"']
elif ret["os"] == "linux" and ret["arch"] == "arm":
ret["system"] = 'linux_arm'
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.']
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.',
'But you can use torrent-client control functions.']
return ret

View File

@ -0,0 +1,74 @@
#-*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 srg70, RussakHH, DiMartino
'''
import os
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':
libname=['libtorrent.so']
elif platform['system'] == 'windows':
libname=['libtorrent.pyd']
elif platform['system'] == 'android' and platform['arch'] == 'arm':
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'}]
self.root=os.path.dirname(__file__)
self._generate_size_file()
def _generate_size_file( self ):
for platform in self.platforms:
for libname in get_libname(platform):
self.libname=libname
self.platform=platform
self.libdir = os.path.join(self.root, self.platform['system'])
self.libpath = os.path.join(self.libdir, self.libname)
self.sizepath=self.libpath+'.size.txt'
self.zipname=self.libname+'.zip'
self.zippath=os.path.join(self.libdir, self.zipname)
if os.path.exists(self.libpath):
if not os.path.exists(self.sizepath):
print platform['system']+'/'+self.libname+' NO SIZE'
self._makezip()
elif not os.path.exists(self.zippath):
print platform['system']+'/'+self.libname+' NO ZIP'
self._makezip()
else:
size=str(os.path.getsize(self.libpath))
size_old=open( self.sizepath, "r" ).read()
if size_old!=size:
print platform['system']+'/'+self.libname+' NOT EQUAL'
self._makezip()
else:
print platform['system']+'/'+self.libname+' NO ACTION'
else:
print platform['system']+'/'+self.libname+' NO LIB'
def _makezip(self):
open( self.sizepath, "w" ).write( str(os.path.getsize(self.libpath)) )
os.chdir(self.libdir)
os.system('del %s' % (self.zipname))
os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
(self.libname, self.libname))
os.chdir(self.root)
#os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
# (self.platform['system']+os.sep+self.libname, self.platform['system']+os.sep+self.libname))
if ( __name__ == "__main__" ):
# start
Public()

View File

@ -1,19 +1,5 @@
#-*- coding: utf-8 -*-
'''
Torrenter plugin for XBMC
Copyright (C) 2012 Vadim Skorba
vadim.skorba@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 DiMartino
'''

View File

@ -0,0 +1 @@
2363904

Binary file not shown.