riorganizzazione cartelle
This commit is contained in:
96
platformcode/backup.py
Normal file
96
platformcode/backup.py
Normal file
@@ -0,0 +1,96 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
# Backup and restore video library
|
||||
# ------------------------------------------------------------
|
||||
|
||||
import datetime, xbmc
|
||||
|
||||
from core import ziptools, videolibrarytools, filetools
|
||||
from platformcode import logger, config, platformtools, xbmc_videolibrary
|
||||
from distutils.dir_util import copy_tree
|
||||
from specials import videolibrary
|
||||
|
||||
temp_path = u'' + xbmc.translatePath("special://userdata/addon_data/plugin.video.kod/temp/")
|
||||
movies_path = u'' + filetools.join(temp_path, "movies")
|
||||
tvshows_path = u'' + filetools.join(temp_path, "tvshows")
|
||||
videolibrary_movies_path = u'' + videolibrarytools.MOVIES_PATH
|
||||
videolibrary_tvshows_path = u'' + videolibrarytools.TVSHOWS_PATH
|
||||
|
||||
|
||||
def export_videolibrary(item):
|
||||
logger.info()
|
||||
|
||||
zip_file_folder = platformtools.dialog_browse(3, config.get_localized_string(80002))
|
||||
if zip_file_folder == "":
|
||||
return
|
||||
zip_file = u'' + xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip")
|
||||
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80003))
|
||||
p_dialog.update(0)
|
||||
|
||||
if filetools.exists(temp_path):
|
||||
filetools.rmdirtree(temp_path)
|
||||
filetools.mkdir(temp_path)
|
||||
p_dialog.update(25)
|
||||
filetools.mkdir(movies_path)
|
||||
copy_tree(videolibrary_movies_path, movies_path)
|
||||
p_dialog.update(50)
|
||||
filetools.mkdir(tvshows_path)
|
||||
copy_tree(videolibrary_tvshows_path, tvshows_path)
|
||||
p_dialog.update(75)
|
||||
|
||||
zipper = ziptools.ziptools()
|
||||
zipper.zip(temp_path, zip_file)
|
||||
|
||||
filetools.rmdirtree(temp_path)
|
||||
|
||||
p_dialog.update(100)
|
||||
xbmc.sleep(1000)
|
||||
p_dialog.close()
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80004), time=5000, sound=False)
|
||||
|
||||
|
||||
def import_videolibrary(item):
|
||||
logger.info()
|
||||
|
||||
zip_file = u'' + platformtools.dialog_browse(1, config.get_localized_string(80005), mask=".zip")
|
||||
if zip_file == "":
|
||||
return
|
||||
if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80006)):
|
||||
return
|
||||
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80007))
|
||||
p_dialog.update(0)
|
||||
|
||||
if filetools.exists(temp_path):
|
||||
filetools.rmdirtree(temp_path)
|
||||
filetools.mkdir(temp_path)
|
||||
|
||||
unzipper = ziptools.ziptools()
|
||||
unzipper.extract(zip_file, temp_path)
|
||||
p_dialog.update(20)
|
||||
|
||||
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
|
||||
xbmc_videolibrary.clean()
|
||||
p_dialog.update(30)
|
||||
filetools.rmdirtree(videolibrary_movies_path)
|
||||
filetools.rmdirtree(videolibrary_tvshows_path)
|
||||
p_dialog.update(50)
|
||||
|
||||
config.verify_directories_created()
|
||||
if filetools.exists(movies_path):
|
||||
copy_tree(movies_path, videolibrary_movies_path)
|
||||
p_dialog.update(70)
|
||||
if filetools.exists(tvshows_path):
|
||||
copy_tree(tvshows_path, videolibrary_tvshows_path)
|
||||
p_dialog.update(90)
|
||||
filetools.rmdirtree(temp_path)
|
||||
|
||||
p_dialog.update(100)
|
||||
xbmc.sleep(1000)
|
||||
p_dialog.close()
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80008), time=5000, sound=False)
|
||||
|
||||
videolibrary.update_videolibrary()
|
||||
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
|
||||
xbmc_videolibrary.update()
|
||||
297
platformcode/checkhost.py
Normal file
297
platformcode/checkhost.py
Normal file
@@ -0,0 +1,297 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import xbmc, xbmcgui
|
||||
import xbmcaddon
|
||||
import json
|
||||
from platformcode import config, logger
|
||||
import requests
|
||||
import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
from lib.httplib2 import py3 as httplib2
|
||||
else:
|
||||
from lib.httplib2 import py2 as httplib2
|
||||
import socket
|
||||
|
||||
addon = xbmcaddon.Addon()
|
||||
addonname = addon.getAddonInfo('name')
|
||||
addonid = addon.getAddonInfo('id')
|
||||
|
||||
LIST_SITE = ['http://www.ansa.it/', 'https://www.google.it']#, 'https://www.google.com']
|
||||
|
||||
# list of sites that will not be reached with the manager's DNS
|
||||
|
||||
LST_SITE_CHCK_DNS = ['https://www.casacinema.me/', 'https://cb01-nuovo-indirizzo.info/']
|
||||
#'https://www.italia-film.pw', 'https://www.cb01.uno/',] # tolti
|
||||
|
||||
class Kdicc():
|
||||
|
||||
def __init__(self, is_exit = True, check_dns = True, view_msg = True,
|
||||
lst_urls = [], lst_site_check_dns = [], in_addon = False):
|
||||
|
||||
self.ip_addr = xbmc.getIPAddress()
|
||||
self.dns = [xbmc.getInfoLabel('Network.DNS1Address'),
|
||||
xbmc.getInfoLabel('Network.DNS2Address')]
|
||||
self.check_dns = check_dns
|
||||
self.is_exit = is_exit
|
||||
self.lst_urls = lst_urls
|
||||
self.view_msg = view_msg
|
||||
self.lst_site_check_dns = lst_site_check_dns
|
||||
self.urls = []
|
||||
#logger.info("check #### INIZIO INIT#### ")
|
||||
|
||||
def check_Ip(self):
|
||||
"""
|
||||
check the ip
|
||||
if ip_addr = 127.0.0.1 or ip_addr = '' then the device does not is connected to the modem/router
|
||||
|
||||
return: bool
|
||||
"""
|
||||
if self.ip_addr == '127.0.0.1' or self.ip_addr == '':
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def check_Adsl(self):
|
||||
"""
|
||||
check if the device reaches the sites
|
||||
"""
|
||||
|
||||
urls = LIST_SITE
|
||||
r = self.rqst(urls)
|
||||
http_errr = 0
|
||||
for rslt in r:
|
||||
xbmc.log("check_Adsl rslt: %s" % rslt['code'], level=xbmc.LOGNOTICE)
|
||||
# Errno -2 could be lack of adsl connection or unreachable site ....
|
||||
# even in cases where there is a change of manager.
|
||||
if rslt['code'] == '111' or '[Errno -3]' in str(rslt['code']) or 'Errno -2' in str(rslt['code']):
|
||||
http_errr +=1
|
||||
|
||||
if len(LIST_SITE) == http_errr:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def check_Dns(self):
|
||||
"""
|
||||
Control if DNS reaches certain sites
|
||||
"""
|
||||
if self.lst_site_check_dns == []:
|
||||
urls = LST_SITE_CHCK_DNS
|
||||
else:
|
||||
urls = self.lst_site_check_dns
|
||||
|
||||
r = self.rqst(urls)
|
||||
xbmc.log("check_Dns result: %s" % r, level=xbmc.LOGNOTICE)
|
||||
http_errr = 0
|
||||
for rslt in r:
|
||||
xbmc.log("check_Dns rslt: %s" % rslt['code'], level=xbmc.LOGNOTICE)
|
||||
if rslt['code'] == '111':
|
||||
http_errr +=1
|
||||
|
||||
if len(LST_SITE_CHCK_DNS) == http_errr:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def rqst(self, lst_urls):
|
||||
"""
|
||||
url must start with http(s):'
|
||||
return : (esito, sito, url, code, reurl)
|
||||
"""
|
||||
rslt_final = []
|
||||
|
||||
if lst_urls == []:
|
||||
lst_urls = self.lst_urls
|
||||
|
||||
for sito in lst_urls:
|
||||
rslt = {}
|
||||
try:
|
||||
r = requests.head(sito, allow_redirects = True) #, timeout=7) # from error after lib insertion of httplib2
|
||||
if r.url.endswith('/'):
|
||||
r.url = r.url[:-1]
|
||||
if str(sito) != str(r.url):
|
||||
is_redirect = True
|
||||
else:
|
||||
is_redirect = False
|
||||
|
||||
rslt['code'] = r.status_code
|
||||
rslt['url'] = str(sito)
|
||||
rslt['rdrcturl'] = str(r.url)
|
||||
rslt['isRedirect'] = is_redirect
|
||||
rslt['history'] = r.history
|
||||
xbmc.log("Risultato nel try: %s" % (r,), level=xbmc.LOGNOTICE)
|
||||
|
||||
except requests.exceptions.ConnectionError as conn_errr:
|
||||
# Errno 10061 for s.o. win
|
||||
# will the Errno 10xxx and 11xxx be to be compacted in any way?
|
||||
# the errors are incorporated in code = '111' since at that moment
|
||||
# they are not reached for any reason
|
||||
if '[Errno 111]' in str(conn_errr) or 'Errno 10060' in str(conn_errr) \
|
||||
or 'Errno 10061' in str(conn_errr) \
|
||||
or '[Errno 110]' in str(conn_errr) \
|
||||
or 'ConnectTimeoutError' in str(conn_errr) \
|
||||
or 'Errno 11002' in str(conn_errr) or 'ReadTimeout' in str(conn_errr) \
|
||||
or 'Errno 11001' in str(conn_errr) \
|
||||
or 'Errno -2' in str(conn_errr): # this error is also in the code: -2
|
||||
rslt['code'] = '111'
|
||||
rslt['url'] = str(sito)
|
||||
rslt['http_err'] = 'Connection error'
|
||||
else:
|
||||
rslt['code'] = conn_errr
|
||||
rslt['url'] = str(sito)
|
||||
rslt['http_err'] = 'Connection refused'
|
||||
rslt_final.append(rslt)
|
||||
|
||||
return rslt_final
|
||||
|
||||
|
||||
def http_Resp(self):
|
||||
rslt = {}
|
||||
for sito in self.lst_urls:
|
||||
try:
|
||||
s = httplib2.Http()
|
||||
code, resp = s.request(sito, body=None)
|
||||
if code.previous:
|
||||
xbmc.log("r1 http_Resp: %s %s %s %s" %
|
||||
(code.status, code.reason, code.previous['status'],
|
||||
code.previous['-x-permanent-redirect-url']), level=xbmc.LOGNOTICE)
|
||||
rslt['code'] = code.previous['status']
|
||||
rslt['redirect'] = code.previous['-x-permanent-redirect-url']
|
||||
rslt['status'] = code.status
|
||||
else:
|
||||
rslt['code'] = code.status
|
||||
except httplib2.ServerNotFoundError as msg:
|
||||
# both for lack of ADSL and for non-existent sites
|
||||
rslt['code'] = -2
|
||||
except socket.error as msg:
|
||||
# for unreachable sites without correct DNS
|
||||
# [Errno 111] Connection refused
|
||||
rslt['code'] = 111
|
||||
except:
|
||||
rslt['code'] = 'Connection error'
|
||||
return rslt
|
||||
|
||||
def view_Advise(self, txt = '' ):
|
||||
"""
|
||||
Notice per user testConnected
|
||||
"""
|
||||
ip = self.check_Ip()
|
||||
if ip:
|
||||
txt += '\nIP: %s\n' % self.ip_addr
|
||||
txt += '\nDNS: %s\n' % (self.dns)
|
||||
else:
|
||||
txt += '\nIP: %s' % self.ip_addr
|
||||
|
||||
dialog = xbmcgui.Dialog()
|
||||
if config.get_setting('checkdns'):
|
||||
risposta= dialog.yesno(addonname, txt, nolabel=config.get_localized_string(707403), yeslabel=config.get_localized_string(707404))
|
||||
if risposta == False:
|
||||
config.set_setting('checkdns', False)
|
||||
dialog.textviewer(addonname+' '+config.get_localized_string(707405), config.get_localized_string(707406))
|
||||
else:
|
||||
txt = config.get_localized_string(707402)
|
||||
dialog.notification(addonname, txt, xbmcgui.NOTIFICATION_INFO, 10000)
|
||||
"""
|
||||
def called in launcher.py
|
||||
"""
|
||||
def test_conn(is_exit, check_dns, view_msg,
|
||||
lst_urls, lst_site_check_dns, in_addon):
|
||||
|
||||
ktest = Kdicc(is_exit, check_dns, view_msg, lst_urls, lst_site_check_dns, in_addon)
|
||||
# if it does not have the IP, I will communicate it to the user
|
||||
if not ktest.check_Ip():
|
||||
# I don't let you get into the addon
|
||||
# enter language code
|
||||
if view_msg == True:
|
||||
ktest.view_Advise(config.get_localized_string(70720))
|
||||
if ktest.is_exit == True:
|
||||
exit()
|
||||
# if it has no ADSL connection, I will communicate it to the user
|
||||
if not ktest.check_Adsl():
|
||||
if view_msg == True:
|
||||
ktest.view_Advise(config.get_localized_string(70721))
|
||||
if ktest.is_exit == True:
|
||||
exit()
|
||||
# if it has DNS filtered, I will communicate it to the user
|
||||
if check_dns == True:
|
||||
if not ktest.check_Dns():
|
||||
if view_msg == True:
|
||||
ktest.view_Advise(config.get_localized_string(70722))
|
||||
|
||||
xbmc.log("############ Start Check DNS ############", level=xbmc.LOGNOTICE)
|
||||
xbmc.log("## IP: %s" % (ktest.ip_addr), level=xbmc.LOGNOTICE)
|
||||
xbmc.log("## DNS: %s" % (ktest.dns), level=xbmc.LOGNOTICE)
|
||||
xbmc.log("############# End Check DNS #############", level=xbmc.LOGNOTICE)
|
||||
# if check_dns == True:
|
||||
# if ktest.check_Ip() == True and ktest.check_Adsl() == True and ktest.check_Dns() == True:
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
# else:
|
||||
# if ktest.check_Ip() == True and ktest.check_Adsl() == True:
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
|
||||
# def for creating the channels.json file
|
||||
def check_channels(inutile=''):
|
||||
"""
|
||||
I read the channel hosts from the channels.json file, I check them,
|
||||
I write the channels-test.json file with the error code and the new url in case of redirect
|
||||
|
||||
urls MUST have http (s)
|
||||
|
||||
During the urls check the ip, asdl and dns checks are carried out.
|
||||
This is because it can happen that at any time the connection may have problems. If it does, check it
|
||||
relative writing of the file is interrupted with a warning message
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
folderJson = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('path')).decode('utf-8')
|
||||
fileJson = 'channels.json'
|
||||
|
||||
with open(folderJson+'/'+fileJson) as f:
|
||||
data = json.load(f)
|
||||
|
||||
risultato = {}
|
||||
|
||||
for chann, host in sorted(data.items()):
|
||||
|
||||
ris = []
|
||||
# to get an idea of the timing
|
||||
# useful only if you control all channels
|
||||
# for channels with error 522 about 40 seconds are lost ...
|
||||
logger.info("check #### INIZIO #### channel - host :%s - %s " % (chann, host))
|
||||
|
||||
rslt = Kdicc(lst_urls = [host]).http_Resp()
|
||||
|
||||
# all right
|
||||
if rslt['code'] == 200:
|
||||
risultato[chann] = host
|
||||
# redirect
|
||||
elif str(rslt['code']).startswith('3'):
|
||||
# risultato[chann] = str(rslt['code']) +' - '+ rslt['redirect'][:-1]
|
||||
if rslt['redirect'].endswith('/'):
|
||||
rslt['redirect'] = rslt['redirect'][:-1]
|
||||
risultato[chann] = rslt['redirect']
|
||||
# non-existent site
|
||||
elif rslt['code'] == -2:
|
||||
risultato[chann] = 'Host Sconosciuto - '+ str(rslt['code']) +' - '+ host
|
||||
# site not reachable - probable dns not set
|
||||
elif rslt['code'] == 111:
|
||||
risultato[chann] = ['Host non raggiungibile - '+ str(rslt['code']) +' - '+ host]
|
||||
else:
|
||||
# other types of errors
|
||||
# risultato[chann] = 'Errore Sconosciuto - '+str(rslt['code']) +' - '+ host
|
||||
risultato[chann] = host
|
||||
|
||||
logger.info("check #### FINE #### rslt :%s " % (rslt))
|
||||
|
||||
fileJson_test = 'channels-test.json'
|
||||
# I write the updated file
|
||||
with open(folderJson+'/'+fileJson_test, 'w') as f:
|
||||
data = json.dump(risultato, f, sort_keys=True, indent=4)
|
||||
logger.info(data)
|
||||
135
platformcode/elementum_download.py
Normal file
135
platformcode/elementum_download.py
Normal file
@@ -0,0 +1,135 @@
|
||||
|
||||
from core import filetools, downloadtools, support
|
||||
from platformcode import config, platformtools, updater
|
||||
import xbmc, xbmcaddon, sys, platform
|
||||
|
||||
host = 'https://github.com'
|
||||
elementum_url = host + '/elgatito/plugin.video.elementum/releases'
|
||||
filename = filetools.join(config.get_data_path(),'elementum.zip')
|
||||
addon_path = xbmc.translatePath('special://home/addons/')
|
||||
setting_path = xbmc.translatePath('special://profile/addon_data/')
|
||||
elementum_path = filetools.join(addon_path,'plugin.video.elementum')
|
||||
elementum_setting = filetools.join(setting_path,'plugin.video.elementum')
|
||||
elementum_setting_file = filetools.join(elementum_setting,'settings.xml')
|
||||
kod_setting_file = filetools.join(addon_path,'plugin.video.kod', 'resources', 'settings', 'elementum', 'settings.xml')
|
||||
|
||||
|
||||
def download(item=None):
|
||||
|
||||
if filetools.exists(elementum_path):
|
||||
if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70783)):
|
||||
setting()
|
||||
platformtools.dialog_ok('Elementum', config.get_localized_string(70783))
|
||||
|
||||
else:
|
||||
if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70782)):
|
||||
pform = get_platform()
|
||||
url = support.match(elementum_url, patronBlock=r'<div class="release-entry">(.*?)<!-- /.release-body -->', patron=r'<a href="([a-zA-Z0-9/\.-]+%s.zip)' % pform).match
|
||||
support.info('OS:', pform)
|
||||
support.info('Extract IN:', elementum_path)
|
||||
support.info('URL:', url)
|
||||
if url:
|
||||
downloadtools.downloadfile(host + url, filename)
|
||||
extract()
|
||||
xbmc.sleep(1000)
|
||||
setting()
|
||||
|
||||
|
||||
def extract():
|
||||
import zipfile
|
||||
from platformcode.updater import fixZipGetHash
|
||||
support.info('Estraggo Elementum in:', elementum_path)
|
||||
try:
|
||||
hash = fixZipGetHash(filename)
|
||||
support.info(hash)
|
||||
|
||||
with zipfile.ZipFile(filetools.file_open(filename, 'rb', vfs=False)) as zip_ref:
|
||||
zip_ref.extractall(xbmc.translatePath(addon_path))
|
||||
|
||||
except Exception as e:
|
||||
support.info('Non sono riuscito ad estrarre il file zip')
|
||||
support.infoger.error(e)
|
||||
import traceback
|
||||
support.infoger.error(traceback.print_exc())
|
||||
|
||||
|
||||
def setting():
|
||||
# support.dbg()
|
||||
xbmc.executebuiltin('UpdateLocalAddons')
|
||||
xbmc.sleep(1000)
|
||||
if filetools.isfile(elementum_setting_file):
|
||||
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.elementum", "enabled": true }}')
|
||||
Continue = True
|
||||
while Continue:
|
||||
try:
|
||||
__settings__ = xbmcaddon.Addon(id="plugin.video.elementum")
|
||||
__settings__.setSetting('skip_burst_search', 'true')
|
||||
__settings__.setSetting('greeting_enabled', 'false')
|
||||
__settings__.setSetting('do_not_disturb', 'true')
|
||||
Continue = False
|
||||
except:
|
||||
support.info('RIPROVO')
|
||||
xbmc.sleep(100)
|
||||
else:
|
||||
if not filetools.exists(elementum_path):
|
||||
filetools.mkdir(elementum_path)
|
||||
filetools.copy(kod_setting_file, elementum_setting_file)
|
||||
xbmc.sleep(1000)
|
||||
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.elementum", "enabled": true }}')
|
||||
|
||||
|
||||
updater.refreshLang()
|
||||
|
||||
if filetools.exists(filename):
|
||||
filetools.remove(filename)
|
||||
|
||||
|
||||
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"] = "arm64"
|
||||
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']
|
||||
1093
platformcode/infoplus.py
Normal file
1093
platformcode/infoplus.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@ def start():
|
||||
# if it has DNS problems start but let in
|
||||
# if everything is ok: enter the addon
|
||||
|
||||
from specials.checkhost import test_conn
|
||||
from platformcode.checkhost import test_conn
|
||||
import threading
|
||||
threading.Thread(target=test_conn, args=(True, not config.get_setting('resolver_dns'), True, [], [], True)).start()
|
||||
|
||||
@@ -37,7 +37,6 @@ def start():
|
||||
updater.showSavedChangelog()
|
||||
|
||||
def run(item=None):
|
||||
from core.support import dbg
|
||||
logger.info()
|
||||
if not item:
|
||||
# Extract item from sys.argv
|
||||
@@ -66,7 +65,7 @@ def run(item=None):
|
||||
category = dictCategory[config.get_setting("category")]
|
||||
item = Item(channel="news", action="novedades", extra=category, mode = 'silent')
|
||||
else:
|
||||
from specials import side_menu
|
||||
from platformcode import side_menu
|
||||
item= Item()
|
||||
item = side_menu.check_user_home(item)
|
||||
item.start = True
|
||||
|
||||
@@ -135,7 +135,7 @@ def render_items(itemlist, parent_item):
|
||||
"""
|
||||
logger.info('START render_items')
|
||||
thumb_type = config.get_setting('video_thumbnail_type')
|
||||
from specials import shortcuts
|
||||
from platformcode import shortcuts
|
||||
from core import httptools
|
||||
_handle = int(sys.argv[1])
|
||||
default_fanart = config.get_fanart()
|
||||
@@ -968,7 +968,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
|
||||
torrent_options = torrent_client_installed(show_tuple=True)
|
||||
if len(torrent_options) == 0:
|
||||
from specials import elementum_download
|
||||
from platformcode import elementum_download
|
||||
elementum_download.download()
|
||||
return play_torrent(item, xlistitem, mediaurl)
|
||||
elif len(torrent_options) > 1:
|
||||
@@ -1136,7 +1136,6 @@ def install_widevine():
|
||||
def download_widevine(version, platform, path):
|
||||
# for x86 architectures
|
||||
from zipfile import ZipFile
|
||||
from xbmcaddon import Addon
|
||||
from core import downloadtools
|
||||
archiveName = 'https://dl.google.com/widevine-cdm/' + version + '-' + platform['os'] + '-' + platform['arch'] + '.zip'
|
||||
fileName = config.get_temp_file('widevine.zip')
|
||||
@@ -1153,7 +1152,6 @@ def download_widevine(version, platform, path):
|
||||
def download_chromeos_image(devices, platform, path):
|
||||
# for arm architectures
|
||||
from core import downloadtools
|
||||
from zipfile import ZipFile
|
||||
from core import jsontools
|
||||
best = best_chromeos_image(devices)
|
||||
archiveName = best['url']
|
||||
|
||||
150
platformcode/shortcuts.py
Normal file
150
platformcode/shortcuts.py
Normal file
@@ -0,0 +1,150 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from platformcode import logger, side_menu
|
||||
|
||||
|
||||
def context():
|
||||
from platformcode import config
|
||||
context = []
|
||||
# original
|
||||
# if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360).upper(), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="shortcut_menu").tourl()))
|
||||
# if config.get_setting('side_menu'): context.append((config.get_localized_string(70737).upper(), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts',action="side_menu").tourl()))
|
||||
# if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="settings_menu").tourl()))
|
||||
|
||||
# pre-serialised
|
||||
if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
||||
if config.get_setting('side_menu'): context.append((config.get_localized_string(70737), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaWRlX21lbnUiLCAKICAgICJjaGFubmVsIjogInNob3J0Y3V0cyIsIAogICAgImluZm9MYWJlbHMiOiB7fQp9)'))
|
||||
if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
||||
|
||||
return context
|
||||
|
||||
def side_menu(item):
|
||||
side_menu.open_menu(item)
|
||||
|
||||
def shortcut_menu(item):
|
||||
from platformcode import keymaptools
|
||||
keymaptools.open_shortcut_menu()
|
||||
|
||||
def settings_menu(item):
|
||||
from platformcode import config
|
||||
config.open_settings()
|
||||
|
||||
def servers_menu(item):
|
||||
# from core.support import dbg; dbg()
|
||||
from core import servertools
|
||||
from core.item import Item
|
||||
from platformcode import config, platformtools
|
||||
from specials import setting
|
||||
|
||||
names = []
|
||||
ids = []
|
||||
|
||||
if item.type == 'debriders':
|
||||
action = 'server_debrid_config'
|
||||
server_list = list(servertools.get_debriders_list().keys())
|
||||
for server in server_list:
|
||||
server_parameters = servertools.get_server_parameters(server)
|
||||
if server_parameters['has_settings']:
|
||||
names.append(server_parameters['name'])
|
||||
ids.append(server)
|
||||
|
||||
select = platformtools.dialog_select(config.get_localized_string(60552), names)
|
||||
ID = ids[select]
|
||||
|
||||
it = Item(channel = 'settings',
|
||||
action = action,
|
||||
config = ID)
|
||||
return setting.server_debrid_config(it)
|
||||
else:
|
||||
action = 'server_config'
|
||||
server_list = list(servertools.get_servers_list().keys())
|
||||
for server in sorted(server_list):
|
||||
server_parameters = servertools.get_server_parameters(server)
|
||||
if server_parameters["has_settings"] and [x for x in server_parameters["settings"] if x["id"] not in ["black_list", "white_list"]]:
|
||||
names.append(server_parameters['name'])
|
||||
ids.append(server)
|
||||
|
||||
select = platformtools.dialog_select(config.get_localized_string(60538), names)
|
||||
ID = ids[select]
|
||||
|
||||
it = Item(channel = 'settings',
|
||||
action = action,
|
||||
config = ID)
|
||||
|
||||
return setting.server_config(it)
|
||||
|
||||
def channels_menu(item):
|
||||
import channelselector
|
||||
from core import channeltools
|
||||
from core.item import Item
|
||||
from platformcode import config, platformtools
|
||||
from specials import setting
|
||||
|
||||
names = []
|
||||
ids = []
|
||||
|
||||
channel_list = channelselector.filterchannels("all")
|
||||
for channel in channel_list:
|
||||
if not channel.channel:
|
||||
continue
|
||||
channel_parameters = channeltools.get_channel_parameters(channel.channel)
|
||||
if channel_parameters["has_settings"]:
|
||||
names.append(channel.title)
|
||||
ids.append(channel.channel)
|
||||
|
||||
select = platformtools.dialog_select(config.get_localized_string(60537), names)
|
||||
ID = ids[select]
|
||||
|
||||
it = Item(channel='settings',
|
||||
action="channel_config",
|
||||
config=ID)
|
||||
|
||||
return setting.channel_config(it)
|
||||
|
||||
def check_channels(item):
|
||||
from specials import setting
|
||||
from platformcode import config, platformtools
|
||||
# from core.support import dbg; dbg()
|
||||
item.channel = 'setting'
|
||||
item.extra = 'lib_check_datajson'
|
||||
itemlist = setting.conf_tools(item)
|
||||
text = ''
|
||||
for item in itemlist:
|
||||
text += item.title + '\n'
|
||||
|
||||
platformtools.dialog_textviewer(config.get_localized_string(60537), text)
|
||||
|
||||
|
||||
def SettingOnPosition(item):
|
||||
# addonId is the Addon ID
|
||||
# item.category is the Category (Tab) offset (0=first, 1=second, 2...etc)
|
||||
# item.setting is the Setting (Control) offse (0=first, 1=second, 2...etc)
|
||||
# This will open settings dialog focusing on fourth setting (control) inside the third category (tab)
|
||||
|
||||
import xbmc
|
||||
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.kod)')
|
||||
category = item.category if item.category else 0
|
||||
setting = item.setting if item.setting else 0
|
||||
logger.info('SETTING= ' + str(setting))
|
||||
xbmc.executebuiltin('SetFocus(%i)' % (category - 100))
|
||||
xbmc.executebuiltin('SetFocus(%i)' % (setting - 80))
|
||||
|
||||
|
||||
def select(item):
|
||||
from platformcode import config, platformtools
|
||||
# item.id = setting ID
|
||||
# item.type = labels or values
|
||||
# item.values = values separeted by |
|
||||
# item.label = string or string id
|
||||
|
||||
label = config.get_localized_string(int(item.label)) if item.label.isdigit() else item.label
|
||||
values = []
|
||||
|
||||
if item.type == 'labels':
|
||||
for val in item.values.split('|'):
|
||||
values.append(config.get_localized_string(int(val)))
|
||||
else:
|
||||
values = item.values.split('|')
|
||||
|
||||
select = platformtools.dialog_select(label, values, config.get_setting(item.id))
|
||||
config.set_setting(item.id, values[select])
|
||||
364
platformcode/side_menu.py
Normal file
364
platformcode/side_menu.py
Normal file
@@ -0,0 +1,364 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# from builtins import str
|
||||
import sys
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
import os
|
||||
from core.item import Item
|
||||
from core import jsontools
|
||||
from platformcode import config, logger, launcher
|
||||
import xbmc, xbmcgui
|
||||
|
||||
media_path = os.path.join(config.get_runtime_path(), "resources/skins/Default/media/side_menu/")
|
||||
menu_settings_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_settings_data.json')
|
||||
|
||||
if os.path.exists(menu_settings_path):
|
||||
menu_node = jsontools.get_node_from_file('menu_setting_data.json', 'menu')
|
||||
else:
|
||||
menu_node = {'categoria actual':config.get_setting('category')}
|
||||
jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
|
||||
|
||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||
|
||||
ACTION_SHOW_FULLSCREEN = 36
|
||||
ACTION_GESTURE_SWIPE_LEFT = 511
|
||||
ACTION_SELECT_ITEM = 7
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_MOVE_LEFT = 1
|
||||
ACTION_MOVE_RIGHT = 2
|
||||
ACTION_MOVE_DOWN = 4
|
||||
ACTION_MOVE_UP = 3
|
||||
|
||||
def set_menu_settings(item):
|
||||
if os.path.exists(menu_settings_path):
|
||||
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
|
||||
else:
|
||||
menu_node = {}
|
||||
menu_node['categoria actual'] = item.extra
|
||||
|
||||
jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
|
||||
|
||||
def check_user_home(item):
|
||||
logger.info()
|
||||
if os.path.exists(menu_settings_path):
|
||||
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
|
||||
if 'user_home' in menu_node:
|
||||
item = Item().fromurl(menu_node['user_home'])
|
||||
else:
|
||||
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
|
||||
from platformcode import platformtools
|
||||
undefined_start = platformtools.dialog_ok(config.get_localized_string(70664), config.get_localized_string(70665) + '\n' + config.get_localized_string(70666))
|
||||
return item
|
||||
|
||||
def set_custom_start(item):
|
||||
logger.info()
|
||||
if os.path.exists(menu_settings_path):
|
||||
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
|
||||
else:
|
||||
menu_node={}
|
||||
parent_item= Item().fromurl(item.parent)
|
||||
parent_item.start=True
|
||||
config.set_setting("custom_start",True)
|
||||
if config.get_setting("news_start"):
|
||||
config.set_setting("news_start", False)
|
||||
menu_node['user_home']=parent_item.tourl()
|
||||
jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
|
||||
|
||||
def get_start_page():
|
||||
logger.info()
|
||||
|
||||
dictCategory = {
|
||||
config.get_localized_string(70137): 'peliculas',
|
||||
config.get_localized_string(30123): 'series',
|
||||
config.get_localized_string(30124): 'anime',
|
||||
config.get_localized_string(70018): 'infantiles',
|
||||
config.get_localized_string(60513): 'documentales',
|
||||
config.get_localized_string(70013): 'terror',
|
||||
config.get_localized_string(30124): 'castellano',
|
||||
config.get_localized_string(59976): 'latino',
|
||||
config.get_localized_string(70171): 'torrent',
|
||||
}
|
||||
category = dictCategory[config.get_setting("category")]
|
||||
|
||||
custom_start= config.get_setting("custom_start")
|
||||
#if category != 'definido':
|
||||
if custom_start == False:
|
||||
item = Item(channel="news", action="novedades", extra=category, mode='silent')
|
||||
else:
|
||||
item = Item()
|
||||
item = side_menu.check_user_home(item)
|
||||
return item
|
||||
|
||||
|
||||
|
||||
def open_menu(item):
|
||||
main = Main('side_menu.xml', config.get_runtime_path())
|
||||
main.doModal()
|
||||
del main
|
||||
|
||||
def open_shortcut_menu(item):
|
||||
from platformcode import keymaptools
|
||||
keymaptools.open_shortcut_menu()
|
||||
|
||||
|
||||
class Main(xbmcgui.WindowXMLDialog):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.items = []
|
||||
|
||||
def onInit(self):
|
||||
#### Kodi 18 compatibility ####
|
||||
if config.get_platform(True)['num_version'] < 18:
|
||||
self.setCoordinateResolution(2)
|
||||
|
||||
self.focus = -1
|
||||
self.buttons = []
|
||||
posx= 0
|
||||
posy= 145
|
||||
space = 30
|
||||
|
||||
selected = 'selected0.png'
|
||||
width = 260
|
||||
height = 30
|
||||
textcolor = "0xFFCCCCCC"
|
||||
conditional_textcolor = "0xFF0081C2"
|
||||
shadow = "0x00000000"
|
||||
offsetx = 30
|
||||
offsety = 5
|
||||
font = 'font25_title'
|
||||
|
||||
if config.get_setting('start_page'):
|
||||
label = config.get_localized_string(70663)
|
||||
self.button_start = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path + selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_start)
|
||||
self.buttons.append(self.button_start)
|
||||
|
||||
posy += space * 2
|
||||
label = config.get_localized_string(70009)
|
||||
self.button_alfa = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path+selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_alfa)
|
||||
self.buttons.append(self.button_alfa)
|
||||
|
||||
|
||||
posy += space
|
||||
label = config.get_localized_string(30100)
|
||||
self.button_config = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path + selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_config)
|
||||
self.buttons.append(self.button_config)
|
||||
posy += space*2
|
||||
label = config.get_localized_string(30122)
|
||||
self.button_peliculas = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
alignment=0x00000000, noFocusTexture='',
|
||||
focusTexture=media_path+selected, textColor=textcolor,
|
||||
shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
self.addControl(self.button_peliculas)
|
||||
self.buttons.append(self.button_peliculas)
|
||||
posy += space
|
||||
label = config.get_localized_string(70017)
|
||||
self.button_series = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
alignment=0x00000000, noFocusTexture='',
|
||||
focusTexture=media_path+selected, textColor=textcolor,
|
||||
shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
self.addControl(self.button_series)
|
||||
self.buttons.append(self.button_series)
|
||||
posy += space
|
||||
label = config.get_localized_string(30124)
|
||||
self.button_anime = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path+selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_anime)
|
||||
self.buttons.append(self.button_anime)
|
||||
# posy += space
|
||||
# label = config.get_localized_string(70018)
|
||||
# self.button_infantil = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
# alignment=0x00000000, noFocusTexture='',
|
||||
# focusTexture=media_path+selected, textColor=textcolor,
|
||||
# shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
# self.addControl(self.button_infantil)
|
||||
# self.buttons.append(self.button_infantil)
|
||||
posy += space
|
||||
label = config.get_localized_string(70019)
|
||||
self.button_docu = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
alignment=0x00000000, noFocusTexture='',
|
||||
focusTexture=media_path + selected, textColor=textcolor,
|
||||
shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
self.addControl(self.button_docu)
|
||||
self.buttons.append(self.button_docu)
|
||||
posy += space
|
||||
|
||||
# label = config.get_localized_string(70013)
|
||||
# self.button_terror = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
# alignment=0x00000000, noFocusTexture='',
|
||||
# focusTexture=media_path+selected, textColor=textcolor,
|
||||
# shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
# self.addControl(self.button_terror)
|
||||
# self.buttons.append(self.button_terror)
|
||||
|
||||
# if channelselector.auto_filter() == 'esp':
|
||||
# posy += space
|
||||
# label = config.get_localized_string(59981)
|
||||
# self.button_lat = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
# noFocusTexture='', focusTexture=media_path+selected,
|
||||
# textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
# textOffsetY=offsety)
|
||||
# self.addControl(self.button_lat)
|
||||
# self.buttons.append(self.button_lat)
|
||||
# posy += space
|
||||
# label = config.get_localized_string(70014)
|
||||
# self.button_cast = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
# noFocusTexture='', focusTexture=media_path + selected,
|
||||
# textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
# textOffsetY=offsety)
|
||||
# self.addControl(self.button_cast)
|
||||
# self.buttons.append(self.button_cast)
|
||||
# posy += space
|
||||
# label = config.get_localized_string(70015)
|
||||
# self.button_torrent = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
# alignment=0x00000000, noFocusTexture='',
|
||||
# focusTexture=media_path+selected, textColor=textcolor,
|
||||
# shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
# self.addControl(self.button_torrent)
|
||||
# self.buttons.append(self.button_torrent)
|
||||
|
||||
start_page_item = get_start_page()
|
||||
if config.get_setting('start_page') and start_page_item.channel == 'news':
|
||||
posy += space
|
||||
label = config.get_localized_string(70016)
|
||||
self.button_config = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
alignment=0x00000000, noFocusTexture='',
|
||||
focusTexture=media_path+selected, textColor=conditional_textcolor,
|
||||
shadowColor=shadow, textOffsetX=offsetx, textOffsetY=offsety)
|
||||
self.addControl(self.button_config)
|
||||
self.buttons.append(self.button_config)
|
||||
|
||||
posy += space*2
|
||||
label = config.get_localized_string(60423)
|
||||
self.button_buscar = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path + selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_buscar)
|
||||
self.buttons.append(self.button_buscar)
|
||||
posy += space
|
||||
label = config.get_localized_string(70036)
|
||||
self.button_actor = xbmcgui.ControlButton(posx, posy, width, height, label, font=font, alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path + selected,
|
||||
textColor=textcolor, shadowColor=shadow, textOffsetX=offsetx,
|
||||
textOffsetY=offsety)
|
||||
self.addControl(self.button_actor)
|
||||
self.buttons.append(self.button_actor)
|
||||
|
||||
posy += space
|
||||
label = config.get_localized_string(70010)
|
||||
self.button_config_search = xbmcgui.ControlButton(posx, posy, width, height, label, font=font,
|
||||
alignment=0x00000000,
|
||||
noFocusTexture='', focusTexture=media_path + selected,
|
||||
textColor=conditional_textcolor, shadowColor=shadow,
|
||||
textOffsetX=offsetx, textOffsetY=offsety)
|
||||
self.addControl(self.button_config_search)
|
||||
self.buttons.append(self.button_config_search)
|
||||
|
||||
|
||||
label=''
|
||||
self.button_close = xbmcgui.ControlButton(260, 0, 1020, 725, label, noFocusTexture='', focusTexture='')
|
||||
self.addControl(self.button_close)
|
||||
|
||||
|
||||
|
||||
def onClick(self, control):
|
||||
new_item=''
|
||||
|
||||
control = self.getControl(control).getLabel()
|
||||
|
||||
if control == config.get_localized_string(70663):
|
||||
new_item = get_start_page()
|
||||
elif control == config.get_localized_string(70009):
|
||||
new_item = Item(channel='', action='getmainlist', title='Menú Alfa')
|
||||
elif control == config.get_localized_string(30100):
|
||||
new_item = Item(channel='setting', action="settings")
|
||||
elif control == config.get_localized_string(30122):
|
||||
new_item = Item(channel='news', action="novedades", extra="peliculas", mode='silent')
|
||||
elif control == config.get_localized_string(70017):
|
||||
new_item = Item(channel='news', action="novedades", extra="series", mode='silent')
|
||||
elif control == config.get_localized_string(30124):
|
||||
new_item = Item(channel='news', action="novedades", extra="anime", mode='silent')
|
||||
elif control == config.get_localized_string(70018):
|
||||
new_item = Item(channel='news', action="novedades", extra="infantiles", mode='silent')
|
||||
elif control == config.get_localized_string(70019):
|
||||
new_item = Item(channel='news', action="novedades", extra="documentales", mode='silent')
|
||||
elif control == config.get_localized_string(70013):
|
||||
new_item = Item(channel='news', action="novedades", extra="terror", mode='silent')
|
||||
elif control == config.get_localized_string(59981):
|
||||
new_item = Item(channel='news', action="novedades", extra="castellano", mode='silent')
|
||||
elif control == config.get_localized_string(70014):
|
||||
new_item = Item(channel='news', action="novedades", extra="latino", mode='silent')
|
||||
elif control == config.get_localized_string(70015):
|
||||
new_item = Item(channel='news', action="novedades", extra="torrent", mode='silent')
|
||||
elif control == config.get_localized_string(70016):
|
||||
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
|
||||
if 'categoria actual' in menu_node:
|
||||
category = menu_node['categoria actual']
|
||||
new_item = Item(channel='news', action="setting_channel", extra=category, menu=True)
|
||||
elif control == config.get_localized_string(60423):
|
||||
new_item = Item(channel='search', action="search")
|
||||
elif control == config.get_localized_string(70036):
|
||||
new_item = Item(channel='tvmoviedb', title="Buscar actor/actriz", action="search_",
|
||||
search={'url': 'search/person', 'language': def_lang, 'page': 1}, star=True)
|
||||
elif control == config.get_localized_string(70010):
|
||||
new_item = Item(channel='search', action="setting_channel")
|
||||
elif control == '':
|
||||
self.close()
|
||||
if new_item !='':
|
||||
self.run_action(new_item)
|
||||
|
||||
|
||||
def onAction(self, action):
|
||||
|
||||
|
||||
if action == ACTION_PREVIOUS_MENU or action == ACTION_GESTURE_SWIPE_LEFT or action == 110 or action == 92:
|
||||
self.close()
|
||||
|
||||
if action == ACTION_MOVE_RIGHT or action == ACTION_MOVE_DOWN:
|
||||
self.focus += 1
|
||||
if self.focus > len(self.buttons)-1:
|
||||
self.focus = 0
|
||||
while True:
|
||||
id_focus = str(self.buttons[self.focus].getId())
|
||||
|
||||
if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'):
|
||||
self.setFocus(self.buttons[self.focus])
|
||||
break
|
||||
self.focus += 1
|
||||
|
||||
if action == ACTION_MOVE_LEFT or action == ACTION_MOVE_UP:
|
||||
self.focus -= 1
|
||||
if self.focus < 0:
|
||||
self.focus = len(self.buttons) - 1
|
||||
while True:
|
||||
id_focus = str(self.buttons[self.focus].getId())
|
||||
if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'):
|
||||
self.setFocus(self.buttons[self.focus])
|
||||
break
|
||||
self.focus -= 1
|
||||
|
||||
def run_action(self, item):
|
||||
logger.info()
|
||||
if item.menu != True:
|
||||
self.close()
|
||||
xbmc.executebuiltin("Container.update(%s)"%launcher.run(item))
|
||||
|
||||
|
||||
|
||||
111
platformcode/updatetvshow.py
Normal file
111
platformcode/updatetvshow.py
Normal file
@@ -0,0 +1,111 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import xbmc, sys, base64, json, xbmcgui, os, xbmcvfs, traceback
|
||||
from platformcode import config, logger
|
||||
from lib.sambatools import libsmb as samba
|
||||
from core import scrapertools
|
||||
|
||||
|
||||
def exists(path, silent=False, vfs=True):
|
||||
path = xbmc.translatePath(path)
|
||||
try:
|
||||
if vfs:
|
||||
result = bool(xbmcvfs.exists(path))
|
||||
if not result and not path.endswith('/') and not path.endswith('\\'):
|
||||
result = bool(xbmcvfs.exists(join(path, ' ').rstrip()))
|
||||
return result
|
||||
elif path.lower().startswith("smb://"):
|
||||
return samba.exists(path)
|
||||
else:
|
||||
return os.path.exists(path)
|
||||
except:
|
||||
logger.error("ERROR when checking the path: %s" % path)
|
||||
if not silent:
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
def join(*paths):
|
||||
list_path = []
|
||||
if paths[0].startswith("/"):
|
||||
list_path.append("")
|
||||
for path in paths:
|
||||
if path:
|
||||
list_path += path.replace("\\", "/").strip("/").split("/")
|
||||
|
||||
if scrapertools.find_single_match(paths[0], r'(^\w+:\/\/)'):
|
||||
return str("/".join(list_path))
|
||||
else:
|
||||
return str(os.sep.join(list_path))
|
||||
|
||||
|
||||
def search_paths(Id):
|
||||
records = execute_sql('SELECT idPath FROM tvshowlinkpath WHERE idShow LIKE "%s"' % Id)
|
||||
if len(records) >= 1:
|
||||
for record in records:
|
||||
path_records = execute_sql('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0])
|
||||
for path in path_records:
|
||||
if config.get_setting('videolibrarypath') in path[0] and exists(join(path[0], 'tvshow.nfo')):
|
||||
return path[0]
|
||||
return ''
|
||||
|
||||
|
||||
def execute_sql(sql):
|
||||
logger.info()
|
||||
file_db = ""
|
||||
records = None
|
||||
|
||||
# We look for the archive of the video database according to the version of kodi
|
||||
video_db = config.get_platform(True)['video_db']
|
||||
if video_db:
|
||||
file_db = os.path.join(xbmc.translatePath("special://userdata/Database"), video_db)
|
||||
|
||||
# alternative method to locate the database
|
||||
if not file_db or not os.path.exists(file_db):
|
||||
file_db = ""
|
||||
for f in os.path.listdir(xbmc.translatePath("special://userdata/Database")):
|
||||
path_f = os.path.join(xbmc.translatePath("special://userdata/Database"), f)
|
||||
|
||||
if os.path.pathoos.pathols.isfile(path_f) and f.lower().startswith('myvideos') and f.lower().endswith('.db'):
|
||||
file_db = path_f
|
||||
break
|
||||
|
||||
if file_db:
|
||||
logger.info("DB file: %s" % file_db)
|
||||
conn = None
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(file_db)
|
||||
cursor = conn.cursor()
|
||||
|
||||
logger.info("Running sql: %s" % sql)
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
|
||||
records = cursor.fetchall()
|
||||
if sql.lower().startswith("select"):
|
||||
if len(records) == 1 and records[0][0] is None:
|
||||
records = []
|
||||
|
||||
conn.close()
|
||||
logger.info("Query executed. Records: %s" % nun_records)
|
||||
|
||||
except:
|
||||
logger.error("Error executing sql query")
|
||||
if conn:
|
||||
conn.close()
|
||||
|
||||
else:
|
||||
logger.debug("Database not found")
|
||||
|
||||
return records
|
||||
|
||||
if __name__ == '__main__':
|
||||
path = search_paths(sys.listitem.getVideoInfoTag().getDbId())
|
||||
if path:
|
||||
item = {"action": "update_tvshow", "channel": "videolibrary", 'path':path}
|
||||
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + base64.b64encode(json.dumps(item).encode()) + ")")
|
||||
else:
|
||||
dialog = xbmcgui.Dialog()
|
||||
title = sys.listitem.getVideoInfoTag().getTitle()
|
||||
if dialog.yesno(title, config.get_localized_string(70817) % title, nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022)):
|
||||
item = {"action": "new_search", "channel": "search", "mode":"tvshow", "search_text": sys.listitem.getVideoInfoTag().getTitle()}
|
||||
xbmc.executebuiltin("ActivateWindow(10025,plugin://plugin.video.kod/?" + base64.b64encode(json.dumps(item).encode()) + ")")
|
||||
Reference in New Issue
Block a user