2015-07-12 02:01:59 +03:00
|
|
|
#-*- coding: utf-8 -*-
|
|
|
|
'''
|
2016-02-03 16:37:49 +03:00
|
|
|
python-libtorrent for Kodi (script.module.libtorrent)
|
|
|
|
Copyright (C) 2015-2016 DiMartino, srg70, RussakHH, aisman
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2015-07-12 02:01:59 +03:00
|
|
|
'''
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
try:
|
2015-07-20 21:12:38 +03:00
|
|
|
import xbmc, xbmcaddon
|
2016-03-11 19:20:59 +03:00
|
|
|
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
|
|
|
|
__version__ = __settings__.getAddonInfo('version')
|
|
|
|
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
|
2015-07-12 02:01:59 +03:00
|
|
|
except:
|
2016-03-11 19:20:59 +03:00
|
|
|
__plugin__ = 'script.module.libtorrent'
|
2015-07-12 02:01:59 +03:00
|
|
|
pass
|
|
|
|
|
2016-03-11 19:20:59 +03:00
|
|
|
def log(msg):
|
|
|
|
try:
|
|
|
|
xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=xbmc.LOGNOTICE )
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
xbmc.log("### [%s]: %s" % (__plugin__,msg.encode("utf-8", "ignore"),), level=xbmc.LOGNOTICE )
|
|
|
|
except:
|
|
|
|
try:
|
|
|
|
xbmc.log("### [%s]: %s" % (__plugin__,'ERROR LOG',), level=xbmc.LOGNOTICE )
|
|
|
|
except:
|
|
|
|
print msg
|
|
|
|
|
2015-07-12 02:01:59 +03:00
|
|
|
def get_libname(platform):
|
|
|
|
libname=[]
|
2016-03-11 19:20:59 +03:00
|
|
|
if platform['system'] in ['darwin', 'linux_x86', 'linux_arm', 'linux_armv6',
|
2016-03-12 21:09:04 +03:00
|
|
|
'linux_armv7', 'linux_x86_64', 'ios_arm',
|
2016-04-14 19:10:16 +03:00
|
|
|
'linux_mipsel_ucs2', 'linux_mipsel_ucs4', 'linux_aarch64']:
|
2015-07-12 02:01:59 +03:00
|
|
|
libname=['libtorrent.so']
|
|
|
|
elif platform['system'] == 'windows':
|
|
|
|
libname=['libtorrent.pyd']
|
2015-07-14 20:42:31 +03:00
|
|
|
elif platform['system'] in ['android_armv7', 'android_x86']:
|
2015-07-12 02:01:59 +03:00
|
|
|
libname=['libtorrent.so', 'liblibtorrent.so']
|
|
|
|
return libname
|
|
|
|
|
|
|
|
def get_platform():
|
2015-07-20 21:12:38 +03:00
|
|
|
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
|
|
|
|
__version__ = __settings__.getAddonInfo('version')
|
|
|
|
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
|
|
|
|
__language__ = __settings__.getLocalizedString
|
|
|
|
|
|
|
|
if __settings__.getSetting('custom_system').lower() == "true":
|
|
|
|
system = int(__settings__.getSetting('set_system'))
|
2016-03-11 19:20:59 +03:00
|
|
|
log('USE CUSTOM SYSTEM: '+__language__(1100+system))
|
2015-07-20 21:12:38 +03:00
|
|
|
|
|
|
|
ret={}
|
|
|
|
|
|
|
|
if system==0:
|
|
|
|
ret["os"] = "windows"
|
|
|
|
ret["arch"] = "x86"
|
|
|
|
elif system==1:
|
|
|
|
ret["os"] = "linux"
|
|
|
|
ret["arch"] = "x86"
|
|
|
|
elif system==2:
|
|
|
|
ret["os"] = "linux"
|
|
|
|
ret["arch"] = "x64"
|
|
|
|
elif system==3:
|
|
|
|
ret["os"] = "linux"
|
2015-07-31 17:35:50 +03:00
|
|
|
ret["arch"] = "armv7"
|
2015-07-20 21:12:38 +03:00
|
|
|
elif system==4:
|
|
|
|
ret["os"] = "linux"
|
2015-07-31 17:35:50 +03:00
|
|
|
ret["arch"] = "armv6"
|
2015-07-20 21:12:38 +03:00
|
|
|
elif system==5:
|
|
|
|
ret["os"] = "android"
|
2015-07-12 02:01:59 +03:00
|
|
|
ret["arch"] = "arm"
|
2015-07-20 21:12:38 +03:00
|
|
|
elif system==6:
|
|
|
|
ret["os"] = "android"
|
|
|
|
ret["arch"] = "x86"
|
|
|
|
elif system==7:
|
|
|
|
ret["os"] = "darwin"
|
|
|
|
ret["arch"] = "x64"
|
|
|
|
elif system==8:
|
|
|
|
ret["os"] = "ios"
|
2015-07-12 02:01:59 +03:00
|
|
|
ret["arch"] = "arm"
|
2015-07-20 21:12:38 +03:00
|
|
|
elif system==9:
|
|
|
|
ret["os"] = "ios"
|
|
|
|
ret["arch"] = "arm"
|
2016-03-11 19:20:59 +03:00
|
|
|
elif system==10:
|
|
|
|
ret["os"] = "linux"
|
2016-03-12 21:09:04 +03:00
|
|
|
ret["arch"] = "mipsel_ucs2"
|
|
|
|
elif system==11:
|
|
|
|
ret["os"] = "linux"
|
|
|
|
ret["arch"] = "mipsel_ucs4"
|
2016-04-14 19:10:16 +03:00
|
|
|
elif system == 12:
|
|
|
|
ret["os"] = "linux"
|
|
|
|
ret["arch"] = "linux_aarch64"
|
2015-07-20 21:12:38 +03:00
|
|
|
else:
|
|
|
|
|
|
|
|
ret = {
|
|
|
|
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
|
|
|
}
|
|
|
|
if xbmc.getCondVisibility("system.platform.android"):
|
|
|
|
ret["os"] = "android"
|
2016-01-04 06:21:51 +03:00
|
|
|
if "arm" in os.uname()[4] or "aarch64" in os.uname()[4]:
|
2015-07-20 21:12:38 +03:00
|
|
|
ret["arch"] = "arm"
|
|
|
|
elif xbmc.getCondVisibility("system.platform.linux"):
|
|
|
|
ret["os"] = "linux"
|
2015-07-31 17:35:50 +03:00
|
|
|
uname=os.uname()[4]
|
|
|
|
if "arm" in uname:
|
2016-01-04 06:21:51 +03:00
|
|
|
if "armv7" in uname:
|
2015-07-30 21:35:28 +03:00
|
|
|
ret["arch"] = "armv7"
|
2015-07-31 17:35:50 +03:00
|
|
|
elif "armv6" in uname:
|
2015-07-30 21:35:28 +03:00
|
|
|
ret["arch"] = "armv6"
|
2016-04-14 19:10:16 +03:00
|
|
|
elif "aarch64" in os.uname()[4]:
|
|
|
|
ret["arch"] = "aarch64"
|
2015-07-31 17:35:50 +03:00
|
|
|
else:
|
|
|
|
ret["arch"] = "arm"
|
2016-03-11 19:20:59 +03:00
|
|
|
elif "mips" in uname:
|
2016-03-12 21:09:04 +03:00
|
|
|
if sys.maxunicode > 65536:
|
|
|
|
ret["arch"] = 'mipsel_ucs4'
|
|
|
|
else:
|
|
|
|
ret["arch"] = 'mipsel_ucs2'
|
2015-07-20 21:12:38 +03:00
|
|
|
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=get_system(ret)
|
|
|
|
return ret
|
2015-07-12 02:01:59 +03:00
|
|
|
|
2015-07-20 21:12:38 +03:00
|
|
|
def get_system(ret):
|
2015-07-12 02:01:59 +03:00
|
|
|
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"']
|
2016-03-11 19:20:59 +03:00
|
|
|
elif ret["os"] == "linux" and ("arm" or "mips" in ret["arch"]):
|
2015-07-30 21:35:28 +03:00
|
|
|
ret["system"] = 'linux_'+ret["arch"]
|
2015-07-12 02:01:59 +03:00
|
|
|
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":
|
|
|
|
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,',
|
2015-07-12 18:54:43 +03:00
|
|
|
'but we need your help with some tests on different processors.']
|
2015-07-12 02:01:59 +03:00
|
|
|
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.']
|
2016-01-17 12:10:26 +03:00
|
|
|
elif ret["os"] == "ios" and ret["arch"] == "arm":
|
|
|
|
ret["system"] = 'ios_arm'
|
2015-07-12 02:01:59 +03:00
|
|
|
ret["message"] = ['It is probably NOT possible to compile python-libtorrent for iOS.',
|
|
|
|
'But you can use torrent-client control functions.']
|
|
|
|
|
|
|
|
return ret
|