custom path & system

pull/1/head
DiMartinoXBMC 2015-07-20 21:12:38 +03:00
parent 07133b8891
commit 64f11899a2
9 changed files with 120 additions and 64 deletions

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<addon id='script.module.libtorrent' version='0.6.19i' name='LibTorrent' provider-name='DiMartino, srg70, RussakHH'>
<addon id='script.module.libtorrent' version='0.6.19k' name='LibTorrent' provider-name='DiMartino, srg70, RussakHH'>
<requires>
<import addon='xbmc.python' version='2.1.0'/>
</requires>

View File

@ -1,4 +1,7 @@
0.6.19c:
0.6.19k:
Added custom library path
0.6.19c:
Added Android x86 0.16.19
0.6.19b:

View File

@ -18,5 +18,5 @@ except Exception, e:
log('Error importing from get_libtorrent(). Exception: ' + str(e))
line2='Python-libtorrent %s IMPORTED successfully' % version if sucsess else 'Failed to import python-libtorrent!'
line2='python-libtorrent %s IMPORTED successfully' % version if sucsess else 'Failed to import python-libtorrent!'
dialog.ok('Libtorrent','OS:'+p['os']+' arch:'+p['arch'], line2)

View File

@ -7,7 +7,7 @@
import sys
import os
try:
import xbmc
import xbmc, xbmcaddon
except:
pass
@ -24,28 +24,73 @@ def get_libname(platform):
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"
__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"
ret["arch"] = "arm"
elif system==6:
ret["os"] = "android"
ret["arch"] = "x86"
elif system==7:
ret["os"] = "darwin"
ret["arch"] = "x64"
elif system==8:
ret["os"] = "ios"
ret["arch"] = "arm"
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
def get_system(ret):
ret["system"] = ''
ret["message"] = ['', '']

View File

@ -12,11 +12,20 @@ import os
__settings__ = xbmcaddon.Addon(id='script.module.libtorrent')
__version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__language__ = __settings__.getLocalizedString
libtorrent=None
platform = get_platform()
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
'python_libtorrent')
set_dirname=__settings__.getSetting('dirname')
log('set_dirname:' +str(set_dirname))
if getSettingAsBool('custom_dirname') and set_dirname:
dirname=set_dirname
else:
dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
'python_libtorrent')
log('dirname:' +str(dirname))
dest_path = os.path.join(dirname, platform['system'])
sys.path.insert(0, dest_path)

View File

@ -9,8 +9,7 @@ __version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__icon__=os.path.join(xbmc.translatePath('special://home'), 'addons',
'script.module.libtorrent', 'icon.png')
#dirname = os.path.join(xbmc.translatePath('special://home'), 'addons', 'script.module.libtorrent')
#sys.path.insert(0, dirname)
__language__ = __settings__.getLocalizedString
from platform_pulsar import get_platform, get_libname
@ -18,7 +17,7 @@ class DownloaderClass():
def __init__(self, dest_path):
self.dest_path = dest_path
self.platform = get_platform()
tempdir(self.platform)
tempdir(self.dest_path)
def tools_download(self):
for libname in get_libname(self.platform):
@ -47,14 +46,13 @@ def log(msg):
except:
xbmc.log("### [%s]: %s" % (__plugin__,'ERROR LOG',), level=xbmc.LOGNOTICE )
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)
def tempdir(dirname):
xbmcvfs.mkdirs(dirname)
return dirname
def getSettingAsBool(setting):
return __settings__.getSetting(setting).lower() == "true"
class LibraryManager():
def __init__(self, dest_path):
self.dest_path = dest_path

View File

@ -1,19 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="1000">Initialization</string>
<string id="1001">Connecting</string>
<string id="1002">Waiting</string>
<string id="1003">Sending Data</string>
<string id="1004">Receiving link</string>
<string id="1005">Playing</string>
<string id="1006">Cancel</string>
<string id="1000">Settings</string>
<string id="1001">Use custom path to library</string>
<string id="1002">Custom path to library</string>
<string id="1003">Disable automatic system detection</string>
<string id="1004">Use library for</string>
<string id="1005"></string>
<string id="1006"></string>
<string id="1100">Pre-buffering</string>
<string id="1101">Buffering</string>
<string id="1102">Downloading</string>
<string id="1103">Verifying data</string>
<string id="1104">TS Engine Idling</string>
<string id="1105">TS Engine Waiting</string>
<string id="1100">Windows 32-bit, 64-bit</string>
<string id="1101">Linux 32-bit</string>
<string id="1102">Linux 64-bit (not ready)</string>
<string id="1103">Linux ARM v7 (RPi 2, not ready)</string>
<string id="1104">Linux ARM v6 (RPi, not ready)</string>
<string id="1105">Android ARM v7</string>
<string id="1106">Android 32-bit</string>
<string id="1107">OS X</string>
<string id="1108">Apple TV2 (not ready)</string>
<string id="1109">iOS (not ready)</string>
<string id="1150">Seeds: %s Speed: %s</string>
<string id="1151">Seconds %s'</string>

View File

@ -1,19 +1,12 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="1000">Инициализация</string>
<string id="1001">Соединение</string>
<string id="1002">Жду ответа</string>
<string id="1003">Передаю данные</string>
<string id="1004">Получаю ссылку</string>
<string id="1005">Начинаю воспроизведение</string>
<string id="1006">Отмена</string>
<string id="1100">Предварительная буферизация</string>
<string id="1101">Буферизация</string>
<string id="1102">Скачивание</string>
<string id="1103">Проверка</string>
<string id="1104">TS Engine бездействует</string>
<string id="1105">TS Engine ожидает</string>
<string id="1000">Настройки</string>
<string id="1001">Изменить путь к библиотеке</string>
<string id="1002">Путь к библиотеке</string>
<string id="1003">Отключить автоматическое определение системы</string>
<string id="1004">Библиотека для</string>
<string id="1005"></string>
<string id="1006"></string>
<string id="1150">Пиры:%s Скорость:%s</string>
<string id="1151">Секунд %ы'</string>

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="Настройки">
<category label="1000">
<setting id="custom_dirname" type="bool" label="1001" default="false" />
<setting id="dirname" type="folder" label="1002" enable="eq(-1,true)" />
<setting id="custom_system" type="bool" label="1003" default="false" />
<setting id="set_system" type="enum" label="1004" enable="eq(-1,true)" default="0" lvalues="1100|1101|1102|1103|1104|1105|1106|1107|1108|1109"/>
</category>
</settings>