script.module.libtorrent/platform_pulsar.py

127 lines
4.7 KiB
Python
Raw Normal View History

2015-07-12 02:01:59 +03:00
#-*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 srg70, RussakHH, DiMartino
'''
import sys
import os
try:
2015-07-20 21:12:38 +03:00
import xbmc, xbmcaddon
2015-07-12 02:01:59 +03:00
except:
pass
def get_libname(platform):
libname=[]
if platform['system'] in ['darwin', 'linux_x86', 'linux_arm', 'linux_x86_64']:
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'))
print 'USE CUSTOM SYSTEM: '+__language__(1100+system)
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"
ret["arch"] = "arm"
elif system==4:
ret["os"] = "linux"
ret["arch"] = "arm"
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"
else:
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.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"']
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":
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.']
elif ret["os"] == "ios":
ret["system"] = 'ios'
ret["message"] = ['It is probably NOT possible to compile python-libtorrent for iOS.',
'But you can use torrent-client control functions.']
return ret