Installa Quasar se il Client interno non funziona
This commit is contained in:
@@ -28,36 +28,36 @@ def init():
|
||||
|
||||
"""
|
||||
Todo el código añadido al add-on se borra con cada actualización. Esta función permite restaurarlo automáticamente con cada actualización. Esto permite al usuario tener su propio código, bajo su responsabilidad, y restaurarlo al add-on cada vez que se actualiza.
|
||||
|
||||
|
||||
El mecanismo funciona copiando el contenido de la carpeta-arbol "./userdata/addon_data/plugin.video.kod/custom_code/..." sobre
|
||||
las carpetas de código del add-on. No verifica el contenido, solo vuelca(reemplaza) el contenido de "custom_code".
|
||||
|
||||
|
||||
El usuario almacenará en las subcarpetas de "custom_code" su código actualizado y listo para ser copiado en cualquier momento.
|
||||
Si no se desea que copie algo, simplemente se borra de "custom_code" y ya no se copiará en la próxima actualización.
|
||||
|
||||
|
||||
Los pasos que sigue esta función, son los siguientes:
|
||||
|
||||
|
||||
1.- La función se llama desde videolibrary_service.py, desde la función inicial:
|
||||
# Copia Custom code a las carpetas de Alfa desde la zona de Userdata
|
||||
from platformcode import custom_code
|
||||
custom_code.init()
|
||||
|
||||
2.- En el inicio de Kodi, comprueba si existe la carpeta "custom_code" en "./userdata/addon_data/plugin.video.kod/".
|
||||
Si no existe, la crea y sale sin más, dando al ususario la posibilidad de copiar sobre esa estructura su código,
|
||||
|
||||
2.- En el inicio de Kodi, comprueba si existe la carpeta "custom_code" en "./userdata/addon_data/plugin.video.kod/".
|
||||
Si no existe, la crea y sale sin más, dando al ususario la posibilidad de copiar sobre esa estructura su código,
|
||||
y que la función la vuelque sobre el add-on en el próximo inicio de Kodi.
|
||||
|
||||
|
||||
3.- En el siguiente inicio de Kodi, comprueba si existe el custom_code.json en la carpeta root del add-on.
|
||||
Si no existe, lo crea con el número de versión del add-on vacío, para permitir que se copien los archivos en esta pasada.
|
||||
|
||||
4.- Verifica que el número de versión del add-on es diferente de el de custom_code.json. Si es la misma versión,
|
||||
|
||||
4.- Verifica que el número de versión del add-on es diferente de el de custom_code.json. Si es la misma versión,
|
||||
se sale porque ya se realizo la copia anteriormente.
|
||||
Si la versión es distinta, se realiza el volcado de todos los archivos de la carpeta-árbol "custom_code" sobre el add-on.
|
||||
Si la carpeta de destino no existe, dará un error y se cancelará la copia. Se considera que no tienen sentido nuevas carpetas.
|
||||
|
||||
|
||||
5.- Si la copia ha terminado con éxito, se actualiza el custom_code.json con el número de versión del add-on,
|
||||
para que en inicios sucesivos de Kodi no se realicen las copias, hasta que el add-on cambie de versión.
|
||||
En el número de versión del add-on no se considera el número de fix.
|
||||
|
||||
|
||||
Tiempos: Copiando 7 archivos de prueba, el proceso ha tardado una décima de segundo.
|
||||
"""
|
||||
|
||||
@@ -65,47 +65,47 @@ def init():
|
||||
#Borra el .zip de instalación de Alfa de la carpeta Packages, por si está corrupto, y que así se pueda descargar de nuevo
|
||||
version = 'plugin.video.kod-%s.zip' % config.get_addon_version(with_fix=False)
|
||||
filetools.remove(filetools.join(xbmc.translatePath('special://home'), 'addons', 'packages', version), True)
|
||||
|
||||
|
||||
#Verifica si Kodi tiene algún achivo de Base de Datos de Vídeo de versiones anteriores, entonces los borra
|
||||
verify_Kodi_video_DB()
|
||||
|
||||
|
||||
#LIBTORRENT: se descarga el binario de Libtorrent cada vez que se actualiza Alfa
|
||||
try:
|
||||
threading.Thread(target=update_libtorrent).start() # Creamos un Thread independiente, hasta el fin de Kodi
|
||||
time.sleep(2) # Dejamos terminar la inicialización...
|
||||
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: 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: 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")
|
||||
|
||||
#Existe carpeta "custom_code" ? Si no existe se crea y se sale
|
||||
custom_code_dir = filetools.join(config.get_data_path(), 'custom_code')
|
||||
if not filetools.exists(custom_code_dir):
|
||||
create_folder_structure(custom_code_dir)
|
||||
return
|
||||
|
||||
|
||||
else:
|
||||
#Existe "custom_code.json" ? Si no existe se crea
|
||||
custom_code_json_path = config.get_runtime_path()
|
||||
custom_code_json = filetools.join(custom_code_json_path, 'custom_code.json')
|
||||
if not filetools.exists(custom_code_json):
|
||||
create_json(custom_code_json_path)
|
||||
|
||||
|
||||
#Se verifica si la versión del .json y del add-on son iguales. Si es así se sale. Si no se copia "custom_code" al add-on
|
||||
verify_copy_folders(custom_code_dir, custom_code_json_path)
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
def create_folder_structure(custom_code_dir):
|
||||
logger.info()
|
||||
@@ -130,18 +130,18 @@ def create_json(custom_code_json_path, json_name=json_data_file_name):
|
||||
if filetools.exists(json_data_file):
|
||||
filetools.remove(json_data_file)
|
||||
result = filetools.write(json_data_file, jsontools.dump({"addon_version": ""}))
|
||||
|
||||
|
||||
return
|
||||
|
||||
|
||||
def verify_copy_folders(custom_code_dir, custom_code_json_path):
|
||||
logger.info()
|
||||
|
||||
|
||||
#verificamos si es una nueva versión de Alfa instalada o era la existente. Si es la existente, nos vamos sin hacer nada
|
||||
json_data_file = filetools.join(custom_code_json_path, json_data_file_name)
|
||||
json_data = jsontools.load(filetools.read(json_data_file))
|
||||
current_version = config.get_addon_version(with_fix=False)
|
||||
if not json_data or not 'addon_version' in json_data:
|
||||
if not json_data or not 'addon_version' in json_data:
|
||||
create_json(custom_code_json_path)
|
||||
json_data = jsontools.load(filetools.read(json_data_file))
|
||||
try:
|
||||
@@ -149,7 +149,7 @@ def verify_copy_folders(custom_code_dir, custom_code_json_path):
|
||||
return
|
||||
except:
|
||||
logger.error(traceback.format_exc(1))
|
||||
|
||||
|
||||
#Ahora copiamos los archivos desde el área de Userdata, Custom_code, sobre las carpetas del add-on
|
||||
for root, folders, files in filetools.walk(custom_code_dir):
|
||||
for file in files:
|
||||
@@ -157,46 +157,46 @@ def verify_copy_folders(custom_code_dir, custom_code_json_path):
|
||||
output_file = input_file.replace(custom_code_dir, custom_code_json_path)
|
||||
if not filetools.copy(input_file, output_file, silent=True):
|
||||
return
|
||||
|
||||
|
||||
#Guardamaos el json con la versión actual de Alfa, para no volver a hacer la copia hasta la nueva versión
|
||||
json_data['addon_version'] = current_version
|
||||
filetools.write(json_data_file, jsontools.dump(json_data))
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def question_update_external_addon(addon_name):
|
||||
logger.info(addon_name)
|
||||
|
||||
|
||||
#Verificamos que el addon está instalado
|
||||
stat = False
|
||||
if xbmc.getCondVisibility('System.HasAddon("plugin.video.%s")' % addon_name):
|
||||
#Si es la primera vez que se pregunta por la actualización del addon externo, recogemos la respuesta,
|
||||
#Si es la primera vez que se pregunta por la actualización del addon externo, recogemos la respuesta,
|
||||
# guardaos un .json en userdat/alfa para no volver a preguntar otra vez, y se actualiza el setting en Alfa.
|
||||
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)
|
||||
|
||||
|
||||
return stat
|
||||
|
||||
|
||||
def update_external_addon(addon_name):
|
||||
logger.info(addon_name)
|
||||
|
||||
|
||||
try:
|
||||
#Verificamos que el addon está instalado
|
||||
if xbmc.getCondVisibility('System.HasAddon("plugin.video.%s")' % addon_name):
|
||||
#Path de actualizaciones de Alfa
|
||||
alfa_addon_updates_mig = filetools.join(config.get_runtime_path(), "lib")
|
||||
alfa_addon_updates = filetools.join(alfa_addon_updates_mig, addon_name)
|
||||
|
||||
|
||||
#Path de destino en addon externo
|
||||
__settings__ = xbmcaddon.Addon(id="plugin.video." + addon_name)
|
||||
if addon_name.lower() in ['quasar', 'elementum']:
|
||||
@@ -206,7 +206,7 @@ def update_external_addon(addon_name):
|
||||
else:
|
||||
addon_path_mig = ''
|
||||
addon_path = ''
|
||||
|
||||
|
||||
#Hay modificaciones en Alfa? Las copiamos al addon, incuidas las carpetas de migración a PY3
|
||||
if filetools.exists(alfa_addon_updates) and filetools.exists(addon_path):
|
||||
for root, folders, files in filetools.walk(alfa_addon_updates_mig):
|
||||
@@ -222,7 +222,7 @@ def update_external_addon(addon_name):
|
||||
if not filetools.copy(input_file, output_file, silent=True):
|
||||
logger.error('Error en la copia de MIGRACIÓN: Input: %s o Output: %s' % (input_file, output_file))
|
||||
return False
|
||||
|
||||
|
||||
for root, folders, files in filetools.walk(alfa_addon_updates):
|
||||
for file in files:
|
||||
input_file = filetools.join(root, file)
|
||||
@@ -241,13 +241,13 @@ def update_external_addon(addon_name):
|
||||
return True
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
def update_libtorrent():
|
||||
logger.info()
|
||||
|
||||
|
||||
if not config.get_setting("mct_buffer", server="torrent", default=""):
|
||||
default = config.get_setting("torrent_client", server="torrent", default=0)
|
||||
config.set_setting("torrent_client", default, server="torrent")
|
||||
@@ -261,10 +261,10 @@ def update_libtorrent():
|
||||
config.set_setting("bt_download_path", config.get_setting("downloadpath"), server="torrent")
|
||||
config.set_setting("mct_download_limit", "", server="torrent")
|
||||
config.set_setting("magnet2torrent", False, server="torrent")
|
||||
|
||||
|
||||
if not filetools.exists(filetools.join(config.get_runtime_path(), "custom_code.json")) or not \
|
||||
config.get_setting("unrar_path", server="torrent", default=""):
|
||||
|
||||
|
||||
path = filetools.join(config.get_runtime_path(), 'lib', 'rarfiles')
|
||||
creationflags = ''
|
||||
sufix = ''
|
||||
@@ -293,7 +293,7 @@ def update_libtorrent():
|
||||
filetools.mkdir(unrar)
|
||||
unrar = filetools.join(unrar, 'unrar')
|
||||
filetools.copy(unrar_org, unrar, silent=True)
|
||||
|
||||
|
||||
command = ['chmod', '777', '%s' % unrar]
|
||||
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output_cmd, error_cmd = p.communicate()
|
||||
@@ -322,14 +322,14 @@ def update_libtorrent():
|
||||
xbmc.log('######## UnRAR ERROR in module %s: %s' % (device, unrar), xbmc.LOGNOTICE)
|
||||
logger.error(traceback.format_exc(1))
|
||||
unrar = ''
|
||||
|
||||
|
||||
if unrar: config.set_setting("unrar_path", unrar, server="torrent")
|
||||
|
||||
if filetools.exists(filetools.join(config.get_runtime_path(), "custom_code.json")) and \
|
||||
config.get_setting("libtorrent_path", server="torrent", default="") :
|
||||
return
|
||||
|
||||
|
||||
|
||||
try:
|
||||
from lib.python_libtorrent.python_libtorrent import get_libtorrent
|
||||
except Exception as e:
|
||||
@@ -339,18 +339,18 @@ def update_libtorrent():
|
||||
config.set_setting("libtorrent_path", "", server="torrent")
|
||||
if not config.get_setting("libtorrent_error", server="torrent", default=''):
|
||||
config.set_setting("libtorrent_error", str(e), server="torrent")
|
||||
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def verify_Kodi_video_DB():
|
||||
logger.info()
|
||||
import random
|
||||
|
||||
|
||||
platform = {}
|
||||
path = ''
|
||||
db_files = []
|
||||
|
||||
|
||||
try:
|
||||
path = filetools.join(xbmc.translatePath("special://masterprofile/"), "Database")
|
||||
if filetools.exists(path):
|
||||
@@ -365,16 +365,16 @@ def verify_Kodi_video_DB():
|
||||
randnum = str(random.randrange(1, 999999))
|
||||
filetools.rename(filetools.join(path, file), 'OLD_' + randnum +'_' + file)
|
||||
logger.error('BD obsoleta: ' + file)
|
||||
|
||||
|
||||
else:
|
||||
logger.error('Video_DB: ' + str(platform['video_db']) + ' para versión Kodi ' + str(platform['num_version']) + ' NO EXISTE. Analizar carpeta: ' + str(db_files))
|
||||
else:
|
||||
logger.error('Estructura de get_platform(full_version=True) incorrecta')
|
||||
else:
|
||||
logger.error('Path a Userdata/Database (' + path + ') no encontrado')
|
||||
|
||||
|
||||
except:
|
||||
logger.error('Platform: ' + str(platform) + ' / Path: ' + str(path) + ' / Files: ' + str(db_files))
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
return
|
||||
@@ -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:
|
||||
|
||||
@@ -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=''), \
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
specials/quasar_download.py
Normal file
100
specials/quasar_download.py
Normal 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']
|
||||
Reference in New Issue
Block a user