Installa Quasar se il Client interno non funziona

This commit is contained in:
Alhaziel
2020-03-14 18:50:10 +01:00
parent 6c0585834f
commit f3d8b87045
7 changed files with 226 additions and 77 deletions
+14 -14
View File
@@ -76,17 +76,17 @@ def init():
except: # Si hay problemas de threading, nos vamos
logger.error(traceback.format_exc())
#QUASAR: Preguntamos si se hacen modificaciones a Quasar
if not filetools.exists(filetools.join(config.get_data_path(), "quasar.json")) \
and not config.get_setting('addon_quasar_update', default=False):
question_update_external_addon("quasar")
# #QUASAR: Preguntamos si se hacen modificaciones a Quasar
# if not filetools.exists(filetools.join(config.get_data_path(), "quasar.json")) \
# and not config.get_setting('addon_quasar_update', default=False):
# question_update_external_addon("quasar")
#QUASAR: Hacemos las modificaciones a Quasar, si está permitido, y si está instalado
if config.get_setting('addon_quasar_update', default=False) or \
(filetools.exists(filetools.join(config.get_data_path(), \
"quasar.json")) and not xbmc.getCondVisibility('System.HasAddon("plugin.video.quasar")')):
if not update_external_addon("quasar"):
platformtools.dialog_notification("Actualización Quasar", "Ha fallado. Consulte el log")
# #QUASAR: Hacemos las modificaciones a Quasar, si está permitido, y si está instalado
# if config.get_setting('addon_quasar_update', default=False) or \
# (filetools.exists(filetools.join(config.get_data_path(), \
# "quasar.json")) and not xbmc.getCondVisibility('System.HasAddon("plugin.video.quasar")')):
# if not update_external_addon("quasar"):
# platformtools.dialog_notification("Actualización Quasar", "Ha fallado. Consulte el log")
#Existe carpeta "custom_code" ? Si no existe se crea y se sale
custom_code_dir = filetools.join(config.get_data_path(), 'custom_code')
@@ -176,10 +176,10 @@ def question_update_external_addon(addon_name):
stat = platformtools.dialog_yesno('Actualización de %s' % addon_name.capitalize(), '¿Quiere que actualicemos Quasar para que sea compatible con las últimas versiones de Kodi? (recomendado: SÍ)', '', 'Si actualiza Quasar, reinicie Kodi en un par de minutos')
#Con la respuesta actualizamos la variable en Alfa settings.xml. Se puede cambiar en Ajustes de Alfa, Otros
if stat:
config.set_setting('addon_quasar_update', True)
else:
config.set_setting('addon_quasar_update', False)
# if stat:
# config.set_setting('addon_quasar_update', True)
# else:
# config.set_setting('addon_quasar_update', False)
#Creamos un .json en userdata para no volver a preguntar otra vez
create_json(config.get_data_path(), "%s.json" % addon_name)
+1 -2
View File
@@ -45,8 +45,7 @@ except:
try:
DOWNLOAD_PATH = ''
DOWNLOAD_PATH = xbmc.translatePath(config.get_setting("mct_download_path", \
server="torrent", default=config.get_setting("downloadpath")))
DOWNLOAD_PATH = xbmc.translatePath(config.get_setting("mct_download_path", server="torrent", default=config.get_setting("torrent_downloadpath")))
except:
DOWNLOAD_PATH = config.get_setting("mct_download_path", server="torrent", default=config.get_setting("downloadpath"))
if not config.get_setting("mct_download_path", server="torrent") and DOWNLOAD_PATH:
+18 -11
View File
@@ -1215,8 +1215,7 @@ def torrent_client_installed(show_tuple=False):
# Plugins externos se encuentra en servers/torrent.json nodo clients
from core import filetools
from core import jsontools
torrent_clients = jsontools.get_node_from_file("torrent.json", "clients", filetools.join(config.get_runtime_path(),
"servers"))
torrent_clients = jsontools.get_node_from_file("torrent.json", "clients", filetools.join(config.get_runtime_path(),"servers"))
torrent_options = []
for client in torrent_clients:
if xbmc.getCondVisibility('System.HasAddon("%s")' % client["id"]):
@@ -1237,6 +1236,17 @@ def play_torrent(item, xlistitem, mediaurl):
from lib import generictools
from servers import torrent
# Si Libtorrent ha dado error de inicialización, no se pueden usar los clientes internos
UNRAR = config.get_setting("unrar_path", server="torrent", default="")
LIBTORRENT = config.get_setting("libtorrent_path", server="torrent", default='')
size_rar = 2
rar_files = []
if item.password:
size_rar = 3
# Opciones disponibles para Reproducir torrents
torrent_options = list()
torrent_options.append([config.get_localized_string(30033)])
@@ -1246,6 +1256,12 @@ def play_torrent(item, xlistitem, mediaurl):
torrent_client = config.get_setting("torrent_client", server="torrent")
# Si es Libtorrent y no está soportado, se ofrecen alternativas, si las hay...
if not LIBTORRENT and len(torrent_options) < 3:
from specials import quasar_download
if dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70782)):
quasar_download.download()
if torrent_client and torrent_client - 1 <= len(torrent_options):
if torrent_client == 0:
seleccion = dialog_select(config.get_localized_string(70193), [opcion[0] for opcion in torrent_options])
@@ -1257,15 +1273,6 @@ def play_torrent(item, xlistitem, mediaurl):
else:
seleccion = 0
# Si Libtorrent ha dado error de inicialización, no se pueden usar los clientes internos
UNRAR = config.get_setting("unrar_path", server="torrent", default="")
LIBTORRENT = config.get_setting("libtorrent_path", server="torrent", default='')
size_rar = 2
rar_files = []
if item.password:
size_rar = 3
# Si es Libtorrent y no está soportado, se ofrecen alternativas, si las hay...
if seleccion < 2 and not LIBTORRENT:
dialog_ok(config.get_localized_string(30033), config.get_localized_string(70774), \
config.get_localized_string(70775) % config.get_setting("libtorrent_error", server="torrent", default=''), \
+25
View File
@@ -5909,6 +5909,31 @@ msgctxt "#70779"
msgid "This will take %s + times the size of the video"
msgstr ""
msgctxt "#70780"
msgid "Elementum with memory download does not support to extract online RAR files (disk occupation %s + times)"
msgstr ""
msgctxt "#70781"
msgid "Do you want to call Elementum Settings to temporarily switch to Use Files?"
msgstr ""
msgctxt "#70782"
msgid "Your device is not compatible with the Internal Client, do you want to use Quasar for Torrents?"
msgstr ""
msgctxt "#70783"
msgid "Quasar installed and configured, enjoy!"
msgstr ""
msgctxt "#70784"
msgid "Attention!!"
msgstr "Attenzione!"
msgctxt "#70785"
msgid "Install external torrent client (Quasar)"
msgstr ""
# DNS start [ settings and declaration ]
msgctxt "#707401"
msgid "Enable DNS Check Alert"
+17
View File
@@ -5921,6 +5921,23 @@ msgctxt "#70781"
msgid "Do you want to call Elementum Settings to temporarily switch to Use Files?"
msgstr "Vuoi aprire i settaggi di Elementum per passare temporaneamente a usare i file?"
msgctxt "#70782"
msgid "Your device is not compatible with the Internal Client, do you want to use Quasar for Torrents?"
msgstr "Il tuo dispositivo non è compatibile con il Client Interno, Vuoi usare Quasar per i Torrent?"
msgctxt "#70783"
msgid "Quasar installed and configured, enjoy!"
msgstr "Quasar installato e configurato, buona Visione!"
msgctxt "#70784"
msgid "Attention!"
msgstr "Attenzione!"
msgctxt "#70785"
msgid "Install external torrent client (Quasar)"
msgstr "Installa client torrent esterno (Quasar)"
# DNS start [ settings and declaration ]
msgctxt "#707401"
msgid "Enable DNS Check Alert"
+1
View File
@@ -128,6 +128,7 @@
<setting id="servers_config" type="action" label="60538" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2VydmVyc19tZW51IiwNCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiDQp9==)"/>
<setting id="debriders_config" type="action" label="60552" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2VydmVyc19tZW51IiwNCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLA0KCSJ0eXBlIjogImRlYnJpZGVycyINCn0==)"/>
<setting id="torrent_config" type="action" label="70253" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiJzZXR0aW5nX3RvcnJlbnQiLA0KICAgICJjaGFubmVsIjoic2V0dGluZyINCn0=)"/>
<setting id="quasar_install" type="action" label="70785" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiJkb3dubG9hZCIsDQogICAgImNoYW5uZWwiOiJxdWFzYXJfZG93bmxvYWQiDQp9)"/>
</category>
<!-- Other -->
+100
View File
@@ -0,0 +1,100 @@
from core import filetools, downloadtools, support
from platformcode import config, platformtools, updater
from time import sleep
import xbmc, xbmcaddon, os, sys, platform
host = 'https://github.com'
quasar_url = host + '/scakemyer/plugin.video.quasar/releases'
filename = filetools.join(config.get_data_path(),'quasar.zip')
addon_path = xbmc.translatePath("special://home/addons/")
quasar_path = filetools.join(addon_path,'plugin.video.quasar')
def download(item=None):
if filetools.exists(quasar_path):
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.quasar", "enabled": false }}')
sleep(1)
filetools.rmdirtree(quasar_path)
if filetools.exists(filename):
filetools.remove(filename)
return download()
else:
platform = get_platform()
support.log('OS:', platform)
support.log('Extract IN:', quasar_path)
url = support.match(quasar_url, patronBlock=r'<div class="release-entry">(.*?)<!-- /.release-body -->', patron=r'<a href="([a-zA-Z0-9/\.-]+%s.zip)' % platform).match
support.log('URL:', url)
if url:
downloadtools.downloadfile(host + url, filename)
extract()
def extract():
import zipfile
support.log('Estraggo Quasar in:', quasar_path)
with zipfile.ZipFile(filename, 'r') as zip_ref:
zip_ref.extractall(xbmc.translatePath("special://home/addons/"))
xbmc.executebuiltin('UpdateLocalAddons')
if platformtools.dialog_ok('Quasar', config.get_localized_string(70783)):
if filetools.exists(filename):
filetools.remove(filename)
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.quasar", "enabled": true }}')
updater.refreshLang()
xbmcaddon.Addon(id="plugin.video.quasar").setSetting('download_path', config.get_setting('downloadpath'))
xbmc.executebuiltin('UpdateLocalAddons')
sleep(2)
def get_platform():
build = xbmc.getInfoLabel("System.BuildVersion")
kodi_version = int(build.split()[0][:2])
ret = {
"auto_arch": sys.maxsize > 2 ** 32 and "64-bit" or "32-bit",
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
"os": "",
"version": platform.release(),
"kodi": kodi_version,
"build": build
}
if xbmc.getCondVisibility("system.platform.android"):
ret["os"] = "android"
if "arm" in platform.machine() or "aarch" in platform.machine():
ret["arch"] = "arm"
if "64" in platform.machine() and ret["auto_arch"] == "64-bit":
ret["arch"] = "arm"
#ret["arch"] = "x64" #The binary is corrupted in install package
elif xbmc.getCondVisibility("system.platform.linux"):
ret["os"] = "linux"
if "aarch" in platform.machine() or "arm64" in platform.machine():
if xbmc.getCondVisibility("system.platform.linux.raspberrypi"):
ret["arch"] = "armv7"
elif ret["auto_arch"] == "32-bit":
ret["arch"] = "armv7"
elif ret["auto_arch"] == "64-bit":
ret["arch"] = "arm64"
elif platform.architecture()[0].startswith("32"):
ret["arch"] = "arm"
else:
ret["arch"] = "arm64"
elif "armv7" in platform.machine():
ret["arch"] = "armv7"
elif "arm" in platform.machine():
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.xbox"):
ret["os"] = "windows"
ret["arch"] = "x64"
elif xbmc.getCondVisibility("system.platform.windows"):
ret["os"] = "windows"
if platform.machine().endswith('64'):
ret["arch"] = "x64"
elif xbmc.getCondVisibility("system.platform.osx"):
ret["os"] = "darwin"
ret["arch"] = "x64"
elif xbmc.getCondVisibility("system.platform.ios"):
ret["os"] = "ios"
ret["arch"] = "arm"
return ret['os'] + '_' + ret['arch']