Merge pull request #185 from Alfa-beto/custom_menu_quick_menu
menu+inicio
This commit is contained in:
@@ -357,19 +357,24 @@ def findvideos(item):
|
||||
data = httptools.downloadpage(item.url).data
|
||||
|
||||
data = re.sub(r"\n|\r|\t|\(.*?\)|\s{2}| ", "", data)
|
||||
patron = '<div id="option-(\d+)" class="play-box-iframe.*?src="([^"]+)" frameborder="0" scrolling="no" allowfullscreen></iframe>'
|
||||
|
||||
patron = '<div id="option-(\d+)" class="play-box-iframe.*?src="([^"]+)" frameborder="0" scrolling="no" ' \
|
||||
'allowfullscreen></iframe>'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
|
||||
for option, url in matches:
|
||||
lang = scrapertools.find_single_match(
|
||||
data, '<li><a class="options" href="#option-%s"><b class="icon-play_arrow"><\/b> (.*?)<span class="dt_flag">' % option)
|
||||
lang = scrapertools.find_single_match(data,
|
||||
'<li><a class="options" href="#option-%s"><b class="icon-play_arrow"><\/b> (.*?)<span '
|
||||
'class="dt_flag">' % option)
|
||||
lang = lang.replace('Español ', '').replace('B.S.O. ', '')
|
||||
|
||||
data_b = httptools.downloadpage(urlparse.urljoin(host, url), headers={'Referer': item.url}).data
|
||||
patron = '<iframe[^>]+src="([^"]+)"'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data_b)
|
||||
url = matches[0]
|
||||
server = servertools.get_server_from_url(url)
|
||||
title = "%s [COLOR yellow](%s) (%s)[/COLOR]" % (item.contentTitle, server.title(), lang)
|
||||
itemlist.append(item.clone(action='play', url=url, title=title, extra1=title,
|
||||
server=server, language = lang, text_color=color3))
|
||||
itemlist.append(item.clone(action='play', url=url, title=title, extra1=title, server=server, language=lang,
|
||||
text_color=color3))
|
||||
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title='[COLOR yellow]Añadir esta pelicula a la videoteca[/COLOR]',
|
||||
|
||||
@@ -15,6 +15,8 @@ from core import scrapertools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger
|
||||
from platformcode import platformtools
|
||||
from core import jsontools
|
||||
from channels import side_menu
|
||||
|
||||
THUMBNAILS = {'0': 'posters', '1': 'banners', '2': 'squares'}
|
||||
|
||||
@@ -27,11 +29,16 @@ perfil = [['0xFF0B7B92', '0xFF89FDFB', '0xFFACD5D4'],
|
||||
['0xFFA5DEE5', '0xFFE0F9B5', '0xFFFEFDCA'],
|
||||
['0xFFF23557', '0xFF22B2DA', '0xFFF0D43A']]
|
||||
|
||||
#color1, color2, color3 = ["white", "white", "white"]
|
||||
color1, color2, color3 = perfil[__perfil__]
|
||||
|
||||
list_newest = []
|
||||
list_newest_tourl = []
|
||||
channels_id_name = {}
|
||||
|
||||
menu_cache_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_cache_data.json')
|
||||
menu_settings_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_settings_data.json')
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
logger.info()
|
||||
@@ -150,6 +157,54 @@ def get_channels_list():
|
||||
|
||||
return list_canales, any_active
|
||||
|
||||
def set_cache(item):
|
||||
logger.info()
|
||||
item.mode = 'set_cache'
|
||||
t = Thread(target=novedades, args=[item])
|
||||
t.start()
|
||||
#t.join()
|
||||
|
||||
def get_from_cache(item):
|
||||
logger.info()
|
||||
itemlist=[]
|
||||
cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached')
|
||||
first=item.last
|
||||
last = first+40
|
||||
#if last >=len(cache_node[item.extra]):
|
||||
# last = len(cache_node[item.extra])
|
||||
|
||||
for cached_item in cache_node[item.extra][first:last]:
|
||||
new_item= Item()
|
||||
new_item = new_item.fromurl(cached_item)
|
||||
itemlist.append(new_item)
|
||||
if item.mode == 'silent':
|
||||
set_cache(item)
|
||||
if last >= len(cache_node[item.extra]):
|
||||
item.mode='finish'
|
||||
itemlist = add_menu_items(item, itemlist)
|
||||
else:
|
||||
item.mode='get_cached'
|
||||
item.last =last
|
||||
itemlist = add_menu_items(item, itemlist)
|
||||
|
||||
return itemlist
|
||||
|
||||
def add_menu_items(item, itemlist):
|
||||
logger.info()
|
||||
|
||||
menu_icon = get_thumb('menu.png')
|
||||
menu = Item(channel="channelselector", action="getmainlist", viewmode="movie", thumbnail=menu_icon, title='Menu')
|
||||
itemlist.insert(0, menu)
|
||||
if item.mode != 'finish':
|
||||
if item.mode == 'get_cached':
|
||||
last=item.last
|
||||
else:
|
||||
last = len(itemlist)
|
||||
refresh_icon = get_thumb('more.png')
|
||||
refresh = item.clone(thumbnail=refresh_icon, mode='get_cached',title='Mas', last=last)
|
||||
itemlist.insert(len(itemlist), refresh)
|
||||
|
||||
return itemlist
|
||||
|
||||
def novedades(item):
|
||||
logger.info()
|
||||
@@ -159,6 +214,14 @@ def novedades(item):
|
||||
list_newest = []
|
||||
start_time = time.time()
|
||||
|
||||
mode = item.mode
|
||||
if mode == '':
|
||||
mode = 'normal'
|
||||
|
||||
if mode=='get_cached':
|
||||
if os.path.exists(menu_cache_path):
|
||||
return get_from_cache(item)
|
||||
|
||||
multithread = config.get_setting("multithread", "news")
|
||||
logger.info("multithread= " + str(multithread))
|
||||
|
||||
@@ -170,8 +233,22 @@ def novedades(item):
|
||||
if config.set_setting("multithread", True, "news"):
|
||||
multithread = True
|
||||
|
||||
progreso = platformtools.dialog_progress(item.category, "Buscando canales...")
|
||||
if mode == 'normal':
|
||||
progreso = platformtools.dialog_progress(item.category, "Buscando canales...")
|
||||
|
||||
list_canales, any_active = get_channels_list()
|
||||
|
||||
if mode=='silent' and any_active and len(list_canales[item.extra]) > 0:
|
||||
side_menu.set_menu_settings(item)
|
||||
aux_list=[]
|
||||
for canal in list_canales[item.extra]:
|
||||
if len(aux_list)<2:
|
||||
aux_list.append(canal)
|
||||
list_canales[item.extra]=aux_list
|
||||
|
||||
if mode == 'set_cache':
|
||||
list_canales[item.extra] = list_canales[item.extra][2:]
|
||||
|
||||
if any_active and len(list_canales[item.extra])>0:
|
||||
import math
|
||||
# fix float porque la division se hace mal en python 2.x
|
||||
@@ -191,12 +268,14 @@ def novedades(item):
|
||||
t = Thread(target=get_newest, args=[channel_id, item.extra], name=channel_title)
|
||||
t.start()
|
||||
threads.append(t)
|
||||
progreso.update(percentage, "", "Buscando en '%s'..." % channel_title)
|
||||
if mode == 'normal':
|
||||
progreso.update(percentage, "", "Buscando en '%s'..." % channel_title)
|
||||
|
||||
# Modo single Thread
|
||||
else:
|
||||
logger.info("Obteniendo novedades de channel_id=" + channel_id)
|
||||
progreso.update(percentage, "", "Buscando en '%s'..." % channel_title)
|
||||
if mode == 'normal':
|
||||
logger.info("Obteniendo novedades de channel_id=" + channel_id)
|
||||
progreso.update(percentage, "", "Buscando en '%s'..." % channel_title)
|
||||
get_newest(channel_id, item.extra)
|
||||
|
||||
# Modo Multi Thread: esperar q todos los hilos terminen
|
||||
@@ -208,25 +287,29 @@ def novedades(item):
|
||||
percentage = int(math.ceil(index * t))
|
||||
|
||||
list_pendent_names = [a.getName() for a in pendent]
|
||||
mensaje = "Buscando en %s" % (", ".join(list_pendent_names))
|
||||
progreso.update(percentage, "Finalizado en %d/%d canales..." % (len(threads) - len(pendent), len(threads)),
|
||||
if mode == 'normal':
|
||||
mensaje = "Buscando en %s" % (", ".join(list_pendent_names))
|
||||
progreso.update(percentage, "Finalizado en %d/%d canales..." % (len(threads) - len(pendent), len(threads)),
|
||||
mensaje)
|
||||
logger.debug(mensaje)
|
||||
logger.debug(mensaje)
|
||||
|
||||
if progreso.iscanceled():
|
||||
logger.info("Busqueda de novedades cancelada")
|
||||
break
|
||||
if progreso.iscanceled():
|
||||
logger.info("Busqueda de novedades cancelada")
|
||||
break
|
||||
|
||||
time.sleep(0.5)
|
||||
pendent = [a for a in threads if a.isAlive()]
|
||||
|
||||
mensaje = "Resultados obtenidos: %s | Tiempo: %2.f segundos" % (len(list_newest), time.time() - start_time)
|
||||
progreso.update(100, mensaje, " ", " ")
|
||||
logger.info(mensaje)
|
||||
start_time = time.time()
|
||||
# logger.debug(start_time)
|
||||
if mode == 'normal':
|
||||
mensaje = "Resultados obtenidos: %s | Tiempo: %2.f segundos" % (len(list_newest), time.time() - start_time)
|
||||
progreso.update(100, mensaje, " ", " ")
|
||||
logger.info(mensaje)
|
||||
start_time = time.time()
|
||||
# logger.debug(start_time)
|
||||
|
||||
result_mode = config.get_setting("result_mode", "news")
|
||||
if mode != 'normal':
|
||||
result_mode=0
|
||||
|
||||
if result_mode == 0: # Agrupados por contenido
|
||||
ret = group_by_content(list_newest)
|
||||
elif result_mode == 1: # Agrupados por canales
|
||||
@@ -237,13 +320,19 @@ def novedades(item):
|
||||
while time.time() - start_time < 2:
|
||||
# mostrar cuadro de progreso con el tiempo empleado durante almenos 2 segundos
|
||||
time.sleep(0.5)
|
||||
|
||||
progreso.close()
|
||||
return ret
|
||||
if mode == 'normal':
|
||||
progreso.close()
|
||||
if mode == 'silent':
|
||||
set_cache(item)
|
||||
item.mode = 'set_cache'
|
||||
ret = add_menu_items(item, ret)
|
||||
if mode != 'set_cache':
|
||||
return ret
|
||||
else:
|
||||
no_channels = platformtools.dialog_ok('Novedades - %s'%item.extra, 'No se ha definido ningun canal para la '
|
||||
'busqueda.','Utilice el menu contextual '
|
||||
'para agregar al menos uno')
|
||||
if mode != 'set_cache':
|
||||
no_channels = platformtools.dialog_ok('Novedades - %s'%item.extra, 'No se ha definido ningun canal para la '
|
||||
'busqueda.','Utilice el menu contextual '
|
||||
'para agregar al menos uno')
|
||||
return
|
||||
|
||||
|
||||
@@ -251,6 +340,7 @@ def get_newest(channel_id, categoria):
|
||||
logger.info("channel_id=" + channel_id + ", categoria=" + categoria)
|
||||
|
||||
global list_newest
|
||||
global list_newest_tourl
|
||||
|
||||
# Solicitamos las novedades de la categoria (item.extra) buscada en el canal channel
|
||||
# Si no existen novedades para esa categoria en el canal devuelve una lista vacia
|
||||
@@ -271,11 +361,22 @@ def get_newest(channel_id, categoria):
|
||||
logger.info("running channel " + modulo.__name__ + " " + modulo.__file__)
|
||||
list_result = modulo.newest(categoria)
|
||||
logger.info("canal= %s %d resultados" % (channel_id, len(list_result)))
|
||||
|
||||
exist=False
|
||||
if os.path.exists(menu_cache_path):
|
||||
cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached')
|
||||
exist=True
|
||||
else:
|
||||
cache_node = {}
|
||||
#logger.debug('cache node: %s' % cache_node)
|
||||
for item in list_result:
|
||||
# logger.info("item="+item.tostring())
|
||||
item.channel = channel_id
|
||||
list_newest.append(item)
|
||||
list_newest_tourl.append(item.tourl())
|
||||
|
||||
cache_node[categoria] = list_newest_tourl
|
||||
|
||||
jsontools.update_node(cache_node, 'menu_cache_data.json', "cached")
|
||||
|
||||
except:
|
||||
logger.error("No se pueden recuperar novedades de: " + channel_id)
|
||||
|
||||
@@ -43,7 +43,7 @@ def newest(categoria):
|
||||
elif categoria == 'terror':
|
||||
item.url = HOST + '/genero/terror.html'
|
||||
itemlist = peliculas(item)
|
||||
if "Pagina" in itemlist[-1].title:
|
||||
if ">> Página siguiente" in itemlist[-1].title:
|
||||
itemlist.pop()
|
||||
except:
|
||||
import sys
|
||||
|
||||
341
plugin.video.alfa/channels/side_menu.py
Normal file
341
plugin.video.alfa/channels/side_menu.py
Normal file
@@ -0,0 +1,341 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
|
||||
import os
|
||||
from core.item import Item
|
||||
from core import jsontools
|
||||
from platformcode import config, logger
|
||||
from platformcode import launcher
|
||||
import xbmc, xbmcgui, xbmcplugin, xbmcaddon
|
||||
|
||||
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")
|
||||
|
||||
|
||||
|
||||
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('Inicio Personalizado', 'No has definido ninguna seccion para mostrar '
|
||||
'en tu inicio', 'Utiliza el menu contextual para definir una')
|
||||
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()
|
||||
|
||||
category = config.get_setting('category').lower()
|
||||
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:
|
||||
from channels import side_menu
|
||||
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
|
||||
|
||||
|
||||
class Main(xbmcgui.WindowXMLDialog):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.items = []
|
||||
|
||||
def onInit(self):
|
||||
self.setCoordinateResolution(2)
|
||||
self.focus = -1
|
||||
self.buttons = []
|
||||
posx= 0
|
||||
posy= 145
|
||||
space = 30
|
||||
|
||||
selected = 'selected.png'
|
||||
width = 260
|
||||
height = 30
|
||||
textcolor = "0xffffd700"
|
||||
conditional_textcolor = "0xffff3030"
|
||||
shadow = "0xFF000000"
|
||||
offsetx = 30
|
||||
offsety = 0
|
||||
font = 'font25_title'
|
||||
|
||||
if config.get_setting('start_page'):
|
||||
label = 'Inicio'
|
||||
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 = 'Menú Clasico'
|
||||
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 = 'Configuracion'
|
||||
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 = 'Peliculas'
|
||||
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 = 'Series'
|
||||
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 = 'Anime'
|
||||
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 = 'Infantiles'
|
||||
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 = 'Documentales'
|
||||
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 = 'Terror'
|
||||
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)
|
||||
|
||||
posy += space
|
||||
label = 'Latino'
|
||||
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 = 'Castellano'
|
||||
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 = 'Torrents'
|
||||
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 = 'Canales Activos'
|
||||
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 = 'Buscar'
|
||||
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 = 'Buscar Actor'
|
||||
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 = 'Donde Buscar'
|
||||
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 == 'Inicio':
|
||||
new_item = get_start_page()
|
||||
elif control == u'Menú Clasico':
|
||||
new_item = Item(channel='', action='getmainlist', title='Menú Alfa')
|
||||
elif control == 'Configuracion':
|
||||
new_item = Item(channel='setting', action="settings")
|
||||
elif control == 'Peliculas':
|
||||
new_item = Item(channel='news', action="novedades", extra="peliculas", mode='silent')
|
||||
elif control == 'Series':
|
||||
new_item = Item(channel='news', action="novedades", extra="series", mode='silent')
|
||||
elif control == 'Anime':
|
||||
new_item = Item(channel='news', action="novedades", extra="anime", mode='silent')
|
||||
elif control == 'Infantiles':
|
||||
new_item = Item(channel='news', action="novedades", extra="infantiles", mode='silent')
|
||||
elif control == 'Documentales':
|
||||
new_item = Item(channel='news', action="novedades", extra="documentales", mode='silent')
|
||||
elif control == 'Terror':
|
||||
new_item = Item(channel='news', action="novedades", extra="terror", mode='silent')
|
||||
elif control == 'Castellano':
|
||||
new_item = Item(channel='news', action="novedades", extra="castellano", mode='silent')
|
||||
elif control == 'Latino':
|
||||
new_item = Item(channel='news', action="novedades", extra="latino", mode='silent')
|
||||
elif control == 'Torrents':
|
||||
new_item = Item(channel='news', action="novedades", extra="torrent", mode='silent')
|
||||
elif control == 'Canales Activos':
|
||||
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 == 'Buscar':
|
||||
new_item = Item(channel='search', action="search")
|
||||
elif control == 'Buscar Actor':
|
||||
new_item = Item(channel='tvmoviedb', title="Buscar actor/actriz", action="search_",
|
||||
search={'url': 'search/person', 'language': 'es', 'page': 1}, star=True)
|
||||
elif control == 'Donde Buscar':
|
||||
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))
|
||||
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ def newest(categoria):
|
||||
return []
|
||||
|
||||
itemlist = scraper(item)
|
||||
if itemlist[-1].title == "» Siguiente »":
|
||||
if itemlist[-1].title == "[COLOR crimson]Siguiente >>[/COLOR]":
|
||||
itemlist.pop()
|
||||
|
||||
# Se captura la excepción, para no interrumpir al canal novedades si un canal falla
|
||||
|
||||
@@ -104,7 +104,7 @@ def get_node_from_file(name_file, node, path=None):
|
||||
if node in dict_data:
|
||||
dict_node = dict_data[node]
|
||||
|
||||
logger.debug("dict_node: %s" % dict_node)
|
||||
#logger.debug("dict_node: %s" % dict_node)
|
||||
|
||||
return dict_node
|
||||
|
||||
|
||||
19
plugin.video.alfa/platformcode/launcher.py
Executable file → Normal file
19
plugin.video.alfa/platformcode/launcher.py
Executable file → Normal file
@@ -14,6 +14,8 @@ from core import videolibrarytools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger
|
||||
from platformcode import platformtools
|
||||
from channelselector import get_thumb
|
||||
|
||||
|
||||
|
||||
def start():
|
||||
@@ -37,8 +39,18 @@ def run(item=None):
|
||||
|
||||
# If no item, this is mainlist
|
||||
else:
|
||||
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
|
||||
if config.get_setting("start_page"):
|
||||
|
||||
if not config.get_setting("custom_start"):
|
||||
category = config.get_setting("category").lower()
|
||||
item = Item(channel="news", action="novedades", extra=category, mode = 'silent')
|
||||
else:
|
||||
from channels import side_menu
|
||||
item= Item()
|
||||
item = side_menu.check_user_home(item)
|
||||
item.start = True;
|
||||
else:
|
||||
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
|
||||
logger.info(item.tostring())
|
||||
|
||||
try:
|
||||
@@ -264,6 +276,11 @@ def run(item=None):
|
||||
else:
|
||||
logger.info("Executing channel '%s' method" % item.action)
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
# if item.start:
|
||||
# menu_icon = get_thumb('menu.png')
|
||||
# menu = Item(channel="channelselector", action="getmainlist", viewmode="movie", thumbnail=menu_icon,
|
||||
# title='Menu')
|
||||
# itemlist.insert(0, menu)
|
||||
platformtools.render_items(itemlist, item)
|
||||
|
||||
except urllib2.URLError, e:
|
||||
|
||||
@@ -18,6 +18,7 @@ import xbmcgui
|
||||
import xbmcplugin
|
||||
from core.item import Item
|
||||
from platformcode import logger
|
||||
from channelselector import get_thumb
|
||||
|
||||
|
||||
def dialog_ok(heading, line1, line2="", line3=""):
|
||||
@@ -95,15 +96,21 @@ def render_items(itemlist, parent_item):
|
||||
"""
|
||||
# Si el itemlist no es un list salimos
|
||||
if not type(itemlist) == list:
|
||||
|
||||
return
|
||||
|
||||
if parent_item.start:
|
||||
menu_icon = get_thumb('menu.png')
|
||||
menu = Item(channel="channelselector", action="getmainlist", viewmode="movie", thumbnail=menu_icon,
|
||||
title='Menu')
|
||||
itemlist.insert(0, menu)
|
||||
|
||||
# Si no hay ningun item, mostramos un aviso
|
||||
if not len(itemlist):
|
||||
itemlist.append(Item(title="No hay elementos que mostrar"))
|
||||
|
||||
# Recorremos el itemlist
|
||||
for item in itemlist:
|
||||
# logger.debug(item)
|
||||
# Si el item no contiene categoria, le ponemos la del item padre
|
||||
if item.category == "":
|
||||
item.category = parent_item.category
|
||||
@@ -181,7 +188,6 @@ def render_items(itemlist, parent_item):
|
||||
if config.get_setting("forceview"):
|
||||
# ...forzamos segun el viewcontent
|
||||
xbmcplugin.setContent(int(sys.argv[1]), parent_item.viewcontent)
|
||||
# logger.debug(parent_item)
|
||||
elif parent_item.channel not in ["channelselector", ""]:
|
||||
# ... o segun el canal
|
||||
xbmcplugin.setContent(int(sys.argv[1]), "movies")
|
||||
@@ -199,9 +205,12 @@ def render_items(itemlist, parent_item):
|
||||
if config.get_setting("forceview"):
|
||||
viewmode_id = get_viewmode_id(parent_item)
|
||||
xbmc.executebuiltin("Container.SetViewMode(%s)" % viewmode_id)
|
||||
if parent_item.mode in ['silent', 'get_cached', 'set_cache','finish']:
|
||||
xbmc.executebuiltin("Container.SetViewMode(500)")
|
||||
|
||||
|
||||
def get_viewmode_id(parent_item):
|
||||
|
||||
# viewmode_json habria q guardarlo en un archivo y crear un metodo para q el user fije sus preferencias en:
|
||||
# user_files, user_movies, user_tvshows, user_season y user_episodes.
|
||||
viewmode_json = {'skin.confluence': {'default_files': 50,
|
||||
@@ -393,7 +402,6 @@ def set_context_commands(item, parent_item):
|
||||
(sys.argv[0], item.clone(channel="favorites", action="addFavourite",
|
||||
from_channel=item.channel,
|
||||
from_action=item.action).tourl())))
|
||||
|
||||
#Buscar en otros canales
|
||||
if item.contentType in ['movie','tvshow']and item.channel != 'search':
|
||||
# Buscar en otros canales
|
||||
@@ -406,8 +414,16 @@ def set_context_commands(item, parent_item):
|
||||
item.clone(channel='search',
|
||||
action="do_search",
|
||||
from_channel=item.channel,
|
||||
contextual=True).tourl())))
|
||||
|
||||
contextual=True).tourl())))
|
||||
#Definir como Pagina de inicio
|
||||
if config.get_setting('start_page'):
|
||||
if item.action not in ['findvideos', 'play']:
|
||||
context_commands.insert(0, ("[COLOR 0xffccff00]Definir como pagina de inicio[/COLOR]",
|
||||
"XBMC.RunPlugin(%s?%s)" % (
|
||||
sys.argv[0], Item(channel='side_menu',
|
||||
action="set_custom_start",
|
||||
parent=item.tourl()).tourl())))
|
||||
|
||||
if item.channel != "videolibrary":
|
||||
# Añadir Serie a la videoteca
|
||||
@@ -468,7 +484,19 @@ def set_context_commands(item, parent_item):
|
||||
context_commands.append(("Super Favourites Menu",
|
||||
"XBMC.RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
||||
|
||||
return sorted(context_commands, key=lambda comand: comand[0])
|
||||
|
||||
|
||||
context_commands = sorted(context_commands, key=lambda comand: comand[0])
|
||||
# Menu Rapido
|
||||
context_commands.insert(0,("[COLOR 0xffccff00]<Menú Rápido>[/COLOR]",
|
||||
"XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
|
||||
action="open_menu",
|
||||
parent=parent_item.tourl()).tourl(
|
||||
|
||||
))))
|
||||
return context_commands
|
||||
|
||||
|
||||
|
||||
|
||||
def is_playing():
|
||||
|
||||
BIN
plugin.video.alfa/resources/media/themes/default/thumb_menu.png
Normal file
BIN
plugin.video.alfa/resources/media/themes/default/thumb_menu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
plugin.video.alfa/resources/media/themes/default/thumb_more.png
Normal file
BIN
plugin.video.alfa/resources/media/themes/default/thumb_more.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
10
plugin.video.alfa/resources/settings.xml
Executable file → Normal file
10
plugin.video.alfa/resources/settings.xml
Executable file → Normal file
@@ -37,6 +37,16 @@
|
||||
<setting id="videolibrary_kodi_flag" type="number" label="" default="0" visible="false"/>
|
||||
<setting id="videolibrary_kodi" type="bool" label="Autoconfigurar videoteca de XBMC/Kodi para contenido de Alfa" enable="lt(-1,2)+eq(0,false)" default="false"/>
|
||||
</category>
|
||||
<category label="Pagina de inicio">
|
||||
<setting id="start_page" type="bool" label="Activar pagina de inicio" default="false"/>
|
||||
<setting id="custom_start" type="bool" label="Personalizado (seleccionar desde un canal)" default="false"
|
||||
visible="eq(-1,True)"/>
|
||||
<setting id="news_start" type="bool" label="Mostrar Novedades" default="false" visible="eq(-2,True)"
|
||||
enable="eq(-1,False)+eq(-2,True"/>
|
||||
<setting id="category" type="labelenum" label="Categoria"
|
||||
values="Peliculas|Series|Anime|Infantiles|Documentales|Terror|Castellano|Latino|Torrent"
|
||||
default="Peliculas" visible="eq(-3,True)+eq(-1,True)+eq(-2,False)" enable="eq(-3,True)+eq(-1,True)+(-2,false)"/>
|
||||
</category>
|
||||
<category label="Opciones Visuales">
|
||||
<setting id="icon_set" type="labelenum" label="Set de iconos" values="default|dark" default="default"/>
|
||||
<setting id="infoplus_set" type="labelenum" label="Opción visual Infoplus" values="Sin animación|Con animación" default="Sin animación"/>
|
||||
|
||||
27
plugin.video.alfa/resources/skins/Default/720p/side_menu.xml
Normal file
27
plugin.video.alfa/resources/skins/Default/720p/side_menu.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<window>
|
||||
<coordinates>
|
||||
<left>0</left>
|
||||
<top>0</top>
|
||||
</coordinates>
|
||||
<zorder>1</zorder>
|
||||
<controls>
|
||||
<control type="image">
|
||||
<animation type="WindowOpen" reversible="false">
|
||||
<effect type="slide" start="-200" end="0" time="80"/>
|
||||
</animation>
|
||||
<left>0</left>
|
||||
<top>0</top>
|
||||
<width>260</width>
|
||||
<height>725</height>
|
||||
<texture border="2">side_menu/bg.png</texture>
|
||||
</control>
|
||||
<control type="image">
|
||||
<left>25</left>
|
||||
<top>30</top>
|
||||
<width>200</width>
|
||||
<height>70</height>
|
||||
<texture border="2">side_menu/logo.png</texture>
|
||||
</control>
|
||||
</controls>
|
||||
</window>
|
||||
BIN
plugin.video.alfa/resources/skins/Default/media/side_menu/bg.png
Normal file
BIN
plugin.video.alfa/resources/skins/Default/media/side_menu/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 351 B |
Reference in New Issue
Block a user