Ejemplo n.º 1
0
    def run(self, path):
        if path:
          item = Item().fromurl(path)
        else:
          item = Item(channel="channelselector", action="mainlist", viewmode="banner")

        launcher.run(item)
Ejemplo n.º 2
0
    def run(self, path):
        if path:
            item = Item().fromurl(path)
        else:
            item = Item(channel="channelselector", action="mainlist", viewmode="banner")

        launcher.run(item)
Ejemplo n.º 3
0
def tmdb_trailers(item, dialog, tipo="movie"):
    logger.debug()

    from core.tmdb import Tmdb
    itemlist = []
    tmdb_search = None
    if item.infoLabels['tmdb_id']:
        tmdb_search = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo, search_language=def_lang)
    elif item.infoLabels['year']:
        tmdb_search = Tmdb(searched_text=item.contentTitle, tipo=tipo, year=item.infoLabels['year'])

    if tmdb_search:
        found = False
        for vid in tmdb_search.get_videos():
            if vid['type'].lower() == 'trailer':
                title = vid['name']
                it = del_id(item.clone(action="play", title=title, title2="TMDB(youtube) - " + vid['language'].replace("en", "ING").replace("it", "ITA") + " [" + vid['size'] + "p]", url=vid['url'], server="youtube"))
                itemlist.append(it)

                if vid['language'] == def_lang and not found:  # play now because lang is correct and TMDB is trusted
                    found = True
                    launcher.run(it)
                    dialog.close()
                    while platformtools.is_playing():
                        xbmc.sleep(100)

    return itemlist
Ejemplo n.º 4
0
def show_result(item):
    tecleado = None
    if item.adult and config.get_setting("adult_request_password"):
        # Solicitar contraseña
        tecleado = platformtools.dialog_input("", config.get_localized_string(60334), True)
        if tecleado is None or tecleado != config.get_setting("adult_password"):
            return []

    item.channel = item.__dict__.pop('from_channel')
    item.action = item.__dict__.pop('from_action')
    if item.__dict__.has_key('tecleado'):
        tecleado = item.__dict__.pop('tecleado')

    try:
        channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
    except:
        import traceback
        logger.error(traceback.format_exc())
        return []

    if tecleado:
        # Mostrar resultados: agrupados por canales
        return channel.search(item, tecleado)
    else:
        # Mostrar resultados: todos juntos
        if item.infoPlus:                       #Si viene de una ventana de InfoPlus, hay que salir de esta forma...
            del item.infoPlus                   #si no, se mete en un bucle mostrando la misma pantalla, 
            item.title = item.title.strip()     #dando error en "handle -1"
            return getattr(channel, item.action)(item)
        try:
            from platformcode import launcher
            launcher.run(item)
        except ImportError:
            return getattr(channel, item.action)(item)
Ejemplo n.º 5
0
def show_result(item):
    tecleado = None
    if item.adult and config.get_setting("adult_request_password"):
        # Solicitar contraseña
        tecleado = platformtools.dialog_input("", "Contraseña para canales de adultos", True)
        if tecleado is None or tecleado != config.get_setting("adult_pin"):
            return []

    item.channel = item.__dict__.pop('from_channel')
    item.action = item.__dict__.pop('from_action')
    if item.__dict__.has_key('tecleado'):
        tecleado = item.__dict__.pop('tecleado')

    try:
        channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
    except:
        import traceback
        logger.error(traceback.format_exc())
        return []


    if tecleado:
        # Mostrar resultados: agrupados por canales
        return channel.search(item, tecleado)
    else:
        # Mostrar resultados: todos juntos
        try:
            from platformcode import launcher
            launcher.run(item)
        except ImportError:
            return getattr(channel, item.action)(item)
Ejemplo n.º 6
0
    def run(self, path):
        if path:
            if isinstance(path, bytes): path = path.decode()
            item = Item().fromurl(path)
        else:
            item = Item(channel="channelselector",
                        action="mainlist",
                        viewmode="banner")

        launcher.run(item)
Ejemplo n.º 7
0
 def onClick(self, control_id):
     setFocus(self)
     if control_id == COMMANDS:
         from platformcode.launcher import run
         pos = self.getControl(COMMANDS).getSelectedPosition()
         if self.commands[pos].action == 'save_download' and self.commands[
                 pos].contentType == 'tvshow':
             actions = [
                 self.commands[-1].clone(),
                 self.commands[-1].clone(download='season')
             ]
             options = [
                 config.get_localized_string(60355),
                 config.get_localized_string(60357)
             ]
             run(actions[platformtools.dialog_select(
                 config.get_localized_string(60498), options)])
         else:
             run(self.commands[pos])
     else:
         action = self.getControl(RECOMANDED).getSelectedItem().getProperty(
             'action')
         channel = self.getControl(
             RECOMANDED).getSelectedItem().getProperty('channel')
         url = self.getControl(RECOMANDED).getSelectedItem().getProperty(
             'url')
         item = Item(channel=channel, action=action, url=url)
         if action == 'play':
             item.server = self.getControl(
                 RECOMANDED).getSelectedItem().getProperty('server')
             self.close()
             platformtools.play_video(item)
             xbmc.sleep(500)
             while xbmc.Player().isPlaying():
                 xbmc.sleep(500)
             modal()
         elif config.get_setting('autoplay'):
             item.quality = self.getControl(
                 RECOMANDED).getSelectedItem().getProperty('quality')
             getattr(self.channel, item.action)(item)
             self.close()
             xbmc.sleep(500)
             while xbmc.Player().isPlaying():
                 xbmc.sleep(500)
             modal()
         else:
             pos = self.getControl(RECOMANDED).getSelectedPosition()
             self.close()
             if self.itemlist[pos].mode: remove()
             Search(self.itemlist[pos])
Ejemplo n.º 8
0
 def playmonitor(self, server=None):
     if server:
         server.window = True
         server.globalsearch = True
         platformtools.prevent_busy(server)
         run(server)
     try:
         while not xbmc.Player().getTime() > 0:
             xbmc.sleep(500)
         self.close()
         xbmc.sleep(500)
         while xbmcgui.getCurrentWindowId() in [12005, 12006]:
             xbmc.sleep(500)
         if platformtools.is_playing():
             xbmc.sleep(300)
             xbmc.executebuiltin('Action(Fullscreen)')
         self.doModal()
     except:
         return
Ejemplo n.º 9
0
# (at your option) any later version.
#
# pelisalacarta 4 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pelisalacarta 4.  If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------
# XBMC entry point
#------------------------------------------------------------

import os
import sys

from core import config
from core import logger

logger.info("pelisalacarta.default init...")

librerias = xbmc.translatePath( os.path.join( config.get_runtime_path(), 'lib' ) )
sys.path.append (librerias)

from platformcode import launcher

if sys.argv[2] == "":
    launcher.start()
    launcher.run()
else:
  launcher.run()
Ejemplo n.º 10
0
 def run_action(self, item):
     logger.info()
     if item.menu != True:
         self.close()
     xbmc.executebuiltin("Container.update(%s)" % launcher.run(item))
Ejemplo n.º 11
0
    from resources.lib.indexers import thegroove360_ext

    thegroove360_ext.indexer_ext().taplist_channels(cat_id=subid)

elif action == 'taplay':
    from resources.lib.indexers import thegroove360_ext

    thegroove360_ext.indexer_ext().taplay(ch_id=subid)

elif action == 'sport365a':
    execfile(os.path.dirname(os.path.realpath(__file__)) + os.sep + 'main.py')

elif action == 'sod':
    launcher.start()
    if item is Item:
        launcher.run(item)
    else:
        launcher.run()

elif action == 'tvtuner':
    from resources.lib.indexers import thegroove360_ext

    thegroove360_ext.indexer_ext().tvtuner(url)

elif 'youtube' in str(action):
    from resources.lib.indexers import thegroove360_ext

    thegroove360_ext.indexer_ext().youtube(url, action)

elif action == 'play3':
    from resources.lib.indexers import thegroove360_ext
Ejemplo n.º 12
0
 def run(self, path):    
     item = self.extract_item(path)
     launcher.run(item)
Ejemplo n.º 13
0
def start(itemlist, item):
    '''
    Metodo principal desde donde se reproduce automaticamente los enlaces
    - En caso la opcion de personalizar activa utilizara las opciones definidas por el usuario.
    - En caso contrario intentara reproducir cualquier enlace que cuente con el idioma preferido.

    :param itemlist: list (lista de items listos para reproducir, o sea con action='play')
    :param item: item (el item principal del canal)
    :return: intenta autoreproducir, en caso de fallar devuelve el itemlist que recibio en un principio
    '''
    logger.info()
    for videoitem in itemlist:
        #Nos dice de donde viene si del addon o videolibrary
        if item.contentChannel == 'videolibrary':
            videoitem.contentEpisodeNumber = item.contentEpisodeNumber
            videoitem.contentPlot = item.contentPlot
            videoitem.contentSeason = item.contentSeason
            videoitem.contentSerieName = item.contentSerieName
            videoitem.contentTitle = item.contentTitle
            videoitem.contentType = item.contentType
            videoitem.episode_id = item.episode_id
            videoitem.hasContentDetails = item.hasContentDetails
            videoitem.infoLabels = item.infoLabels
            videoitem.thumbnail = item.thumbnail
            #videoitem.title=item.title
    if not config.is_xbmc():
        #platformtools.dialog_notification('AutoPlay ERROR', 'Sólo disponible para XBMC/Kodi')
        return itemlist

    global autoplay_node
    if not autoplay_node:
        # Obtiene el nodo AUTOPLAY desde el json
        autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')

    if not item.channel in autoplay_node:
        return itemlist

    # Agrega servidores y calidades que no estaban listados a autoplay_node
    new_options = check_value(item.channel, itemlist)

    # Obtiene el nodo del canal desde autoplay_node
    channel_node = autoplay_node.get(item.channel, {})
    # Obtiene los ajustes des autoplay para este canal
    settings_node = channel_node.get('settings', {})

    if settings_node['active']:
        url_list_valid = []
        autoplay_list = []
        favorite_servers = []
        favorite_quality = []

        # Guarda el valor actual de "Accion y Player Mode" en preferencias
        user_config_setting_action = config.get_setting("default_action")
        user_config_setting_player = config.get_setting("player_mode")
        # Habilita la accion "Ver en calidad alta" (si el servidor devuelve más de una calidad p.e. gdrive)
        if user_config_setting_action != 2:
            config.set_setting("default_action", 2)
        if user_config_setting_player != 0:
            config.set_setting("player_mode", 0)

        # Informa que AutoPlay esta activo
        platformtools.dialog_notification('AutoPlay Activo', '', sound=False)

        # Prioridades a la hora de ordenar itemlist:
        #       0: Servidores y calidades
        #       1: Calidades y servidores
        #       2: Solo servidores
        #       3: Solo calidades
        #       4: No ordenar
        if settings_node['custom_servers'] and settings_node['custom_quality']:
            priority = settings_node[
                'priority']  # 0: Servidores y calidades o 1: Calidades y servidores
        elif settings_node['custom_servers']:
            priority = 2  # Solo servidores
        elif settings_node['custom_quality']:
            priority = 3  # Solo calidades
        else:
            priority = 4  # No ordenar

        # Obtiene las listas servidores, calidades disponibles desde el nodo del json de AutoPlay
        server_list = channel_node.get('servers', [])
        quality_list = channel_node.get('quality', [])

        # Si no se definen calidades la se asigna default como calidad unica
        if len(quality_list) == 0:
            quality_list = ['default']

        # Se guardan los textos de cada servidor y calidad en listas p.e. favorite_servers = ['openload',
        # 'streamcloud']
        for num in range(1, 4):
            favorite_servers.append(
                channel_node['servers'][settings_node['server_%s' % num]])
            favorite_quality.append(
                channel_node['quality'][settings_node['quality_%s' % num]])

        # Se filtran los enlaces de itemlist y que se correspondan con los valores de autoplay
        for item in itemlist:
            autoplay_elem = dict()

            # Comprobamos q se trata de un item de video
            if 'server' not in item:
                continue

            # Agrega la opcion configurar AutoPlay al menu contextual
            if 'context' not in item:
                item.context = list()
            if not filter(lambda x: x['action'] == 'autoplay_config', context):
                item.context.append({
                    "title": "Configurar AutoPlay",
                    "action": "autoplay_config",
                    "channel": "autoplay",
                    "from_channel": item.channel
                })

            # Si no tiene calidad definida le asigna calidad 'default'
            if item.quality == '':
                item.quality = 'default'

            # Se crea la lista para configuracion personalizada
            if priority < 2:  # 0: Servidores y calidades o 1: Calidades y servidores

                # si el servidor y la calidad no se encuentran en las listas de favoritos o la url esta repetida,
                # descartamos el item
                if item.server not in favorite_servers or item.quality not in favorite_quality \
                        or item.url in url_list_valid:
                    continue
                autoplay_elem["indice_server"] = favorite_servers.index(
                    item.server)
                autoplay_elem["indice_quality"] = favorite_quality.index(
                    item.quality)

            elif priority == 2:  # Solo servidores

                # si el servidor no se encuentra en la lista de favoritos o la url esta repetida,
                # descartamos el item
                if item.server not in favorite_servers or item.url in url_list_valid:
                    continue
                autoplay_elem["indice_server"] = favorite_servers.index(
                    item.server)

            elif priority == 3:  # Solo calidades

                # si la calidad no se encuentra en la lista de favoritos o la url esta repetida,
                # descartamos el item
                if item.quality not in favorite_quality or item.url in url_list_valid:
                    continue
                autoplay_elem["indice_quality"] = favorite_quality.index(
                    item.quality)

            else:  # No ordenar

                # si la url esta repetida, descartamos el item
                if item.url in url_list_valid:
                    continue

            # Si el item llega hasta aqui lo añadimos al listado de urls validas y a autoplay_list
            url_list_valid.append(item.url)
            autoplay_elem['videoitem'] = item
            # autoplay_elem['server'] = item.server
            # autoplay_elem['quality'] = item.quality
            autoplay_list.append(autoplay_elem)

        # Ordenamos segun la prioridad
        if priority == 0:  # Servidores y calidades
            autoplay_list.sort(key=lambda orden: (orden['indice_server'],
                                                  orden['indice_quality']))

        elif priority == 1:  # Calidades y servidores
            autoplay_list.sort(key=lambda orden: (orden['indice_quality'],
                                                  orden['indice_server']))

        elif priority == 2:  # Solo servidores
            autoplay_list.sort(key=lambda orden: orden['indice_server'])

        elif priority == 3:  # Solo calidades
            autoplay_list.sort(key=lambda orden: orden['indice_quality'])

        # Si hay elementos en la lista de autoplay se intenta reproducir cada elemento, hasta encontrar uno
        # funcional o fallen todos
        if autoplay_list:
            played = False
            max_intentos = 5
            max_intentos_servers = {}

            # Si se esta reproduciendo algo detiene la reproduccion
            if platformtools.is_playing():
                platformtools.stop_video()

            for autoplay_elem in autoplay_list:
                if not platformtools.is_playing() and not played:
                    videoitem = autoplay_elem['videoitem']

                    if videoitem.server not in max_intentos_servers:
                        max_intentos_servers[videoitem.server] = max_intentos

                    # Si se han alcanzado el numero maximo de intentos de este servidor saltamos al siguiente
                    if max_intentos_servers[videoitem.server] == 0:
                        continue

                    lang = " "
                    if hasattr(videoitem,
                               'language') and videoitem.language != "":
                        lang = " '%s' " % videoitem.language

                    platformtools.dialog_notification(
                        "AutoPlay",
                        "%s%s%s" % (videoitem.server.upper(), lang,
                                    videoitem.quality.upper()),
                        sound=False)
                    # TODO videoitem.server es el id del server, pero podria no ser el nombre!!!

                    # Intenta reproducir los enlaces
                    # Si el canal tiene metodo play propio lo utiliza
                    channel = __import__('channels.%s' % item.channel, None,
                                         None, ["channels.%s" % item.channel])
                    if hasattr(channel, 'play'):
                        resolved_item = getattr(channel, 'play')(videoitem)
                        if len(resolved_item) > 0:
                            if isinstance(resolved_item[0], list):
                                videoitem.video_urls = resolved_item
                            else:
                                videoitem = resolved_item[0]

                    # si no directamente reproduce y marca como visto
                    from platformcode import xbmc_videolibrary
                    xbmc_videolibrary.mark_auto_as_watched(item)
                    #platformtools.play_video(videoitem)
                    videoitem.contentChannel = 'videolibrary'
                    launcher.run(videoitem)

                    try:
                        if platformtools.is_playing():
                            played = True
                            break
                    except:  # TODO evitar el informe de que el conector fallo o el video no se encuentra
                        logger.debug(str(len(autoplay_list)))

                    # Si hemos llegado hasta aqui es por q no se ha podido reproducir
                    max_intentos_servers[videoitem.server] -= 1

                    # Si se han alcanzado el numero maximo de intentos de este servidor
                    # preguntar si queremos seguir probando o lo ignoramos
                    if max_intentos_servers[videoitem.server] == 0:
                        text = "Parece que los enlaces de %s no estan funcionando." % videoitem.server.upper(
                        )
                        if not platformtools.dialog_yesno(
                                "AutoPlay", text,
                                "¿Desea ignorar todos los enlaces de este servidor?"
                        ):
                            max_intentos_servers[
                                videoitem.server] = max_intentos

        else:
            platformtools.dialog_notification('AutoPlay No Fue Posible',
                                              'No Hubo Coincidencias')
        if new_options:
            platformtools.dialog_notification(
                "AutoPlay", "Nueva Calidad/Servidor disponible en la "
                "configuracion",
                sound=False)

        # Restaura si es necesario el valor previo de "Accion y Player Mode" en preferencias
        if user_config_setting_action != 2:
            config.set_setting("default_action", user_config_setting_action)
        if user_config_setting_player != 0:
            config.set_setting("player_mode", user_config_setting_player)

    # devuelve la lista de enlaces para la eleccion manual
    return itemlist
Ejemplo n.º 14
0
 def run(self, path):
     item = self.extract_item(path)
     from platformcode import launcher
     launcher.run(item)
Ejemplo n.º 15
0
 def run(self, path):    
     item = self.extract_item(path)
     from platformcode import launcher
     launcher.run(item)
Ejemplo n.º 16
0
 def play(self, server=None):
     platformtools.prevent_busy(server)
     server.window = True
     server.globalsearch = True
     return run(server)
Ejemplo n.º 17
0
# -*- coding: iso-8859-1 -*-
#------------------------------------------------------------
# pelisalacarta
# XBMC entry point
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------

# Constants
__plugin__  = "pelisalacarta"
__author__  = "pelisalacarta"
__url__     = "http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/"
__date__ = "26/03/2015"
__version__ = "4.0"

import os
import sys
from core import config
from core import logger

logger.info("pelisalacarta.default init...")

librerias = xbmc.translatePath( os.path.join( config.get_runtime_path(), 'lib' ) )
sys.path.append (librerias)

# Runs xbmc launcher
from platformcode import launcher
launcher.run()
Ejemplo n.º 18
0
    def onClick(self, control_id):
        if self.RESULTS.getSelectedItem(): search = self.RESULTS.getSelectedItem().getProperty('search')
        else: search = None
        if control_id in [CHANNELS]:
            items = []
            name = self.CHANNELS.getSelectedItem().getLabel()
            subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
            for result in self.results[name][0]:
                items.append(self.makeItem(result))
            self.RESULTS.reset()
            self.RESULTS.addItems(items)
            self.RESULTS.selectItem(subpos)
            self.CHANNELS.getSelectedItem().setProperty('position', str(subpos))
            # self.setFocusId(RESULTS)

        elif control_id in [BACK]:
            self.Back()

        elif control_id in [CLOSE]:
            self.Close()

        elif search:
            pos = self.RESULTS.getSelectedPosition()
            if search == 'next':
                self.page += 1
                self.actors()
            elif search == 'previous':
                self.page -= 1
                self.actors()
            elif search == 'persons':
                self.item.discovery = self.persons[pos]
                self.select()
            else:
                result = self.find[pos]
                name = self.RESULTS.getSelectedItem().getLabel()
                item = Item(mode='search', type=result['mode'], contentType=result['mode'], infoLabels=result, selected = True, text=name)
                if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
                else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
                return Search(item)

        elif control_id in [RESULTS, EPISODESLIST]:
            busy(True)
            if control_id in [RESULTS]:
                name = self.CHANNELS.getSelectedItem().getLabel()
                self.pos = self.RESULTS.getSelectedPosition()
                item = self.results[name][0][self.pos]
            else:
                self.pos = self.EPISODESLIST.getSelectedPosition()
                item = self.episodes[self.pos]
            # dbg()
            self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
            self.itemsResult = getattr(self.channel, item.action)(item)

            if self.itemsResult and self.itemsResult[0].action in ['play']:

                if config.get_setting('checklinks') and not config.get_setting('autoplay'):
                    self.itemsResult = servertools.check_list_links(self.itemsResult, config.get_setting('checklinks_number'))
                self.servers = self.itemsResult
                self.itemsResult = []
                uhd = []
                fhd = []
                hd = []
                sd = []
                unknown = []
                for i, item in enumerate(self.servers):
                    if item.server:
                        it = self.makeItem(item)
                        it.setProperty('index', str(i))
                        if item.quality in ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k']:
                            it.setProperty('quality', 'uhd.png')
                            uhd.append(it)
                        elif item.quality in ['fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p']:
                            it.setProperty('quality', 'Fhd.png')
                            fhd.append(it)
                        elif item.quality in ['hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv']:
                            it.setProperty('quality', 'hd.png')
                            hd.append(it)
                        elif item.quality in ['sd', '480p', '480', '360p', '360', '240p', '240']:
                            it.setProperty('quality', 'sd.png')
                            sd.append(it)
                        else:
                            it.setProperty('quality', '')
                            unknown.append(it)

                uhd.sort(key=lambda it: it.getProperty('index'))
                fhd.sort(key=lambda it: it.getProperty('index'))
                hd.sort(key=lambda it: it.getProperty('index'))
                sd.sort(key=lambda it: it.getProperty('index'))
                unknown.sort(key=lambda it: it.getProperty('index'))

                serverlist = uhd + fhd + hd + sd + unknown

                self.Focus(SERVERS)
                self.SERVERLIST.reset()
                self.SERVERLIST.addItems(serverlist)
                self.setFocusId(SERVERLIST)

            else:
                self.episodes = self.itemsResult
                self.itemsResult = []
                episodes = []
                for item in self.episodes:
                    if item.action == 'findvideos':
                        it = xbmcgui.ListItem(item.title)
                        episodes.append(it)

                self.Focus(EPISODES)
                self.EPISODESLIST.reset()
                self.EPISODESLIST.addItems(episodes)
                self.setFocusId(EPISODESLIST)

            busy(False)

        elif control_id in [SERVERLIST]:
            index = int(self.getControl(control_id).getSelectedItem().getProperty('index'))
            server = self.servers[index]
            server.player_mode = 0
            run(server)