def search(params, url, category):
    
    logger.info('channelselector.search')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    query = CommonFunctions.getUserInput("Buscar", '')
    #logger.info("QUERY: %s"% query)

    if not query or query == '':
        return
    
    search = API.search(search_term=query)
    logger.info("SEARCHRESULT %s" % search)
    for item in search:
        if item.has_key('title') and item.has_key('mediaType') and item.has_key('idm'):
            params = {'title': item['title'],
                      'mediaType':item['mediaType'], 
                      'idm' : item['idm']}
            if item.has_key('idMedia'):
                params['idMedia'] = item['idMedia']
            title = item['title']
            if item.has_key('year'):
                title = '%s [%s]' % (item['title'], item['year'])
            thumbnail = item.get('img', '').replace(' ','')
            addfolder(name=title, 
                      channelname=serialize(params), 
                      action='details',
                      thumbnail=thumbnail)

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def serie_details_old(params, url, category):
    #TODO: Funciona esto?
    logger.info('channelselector.serie_details_old')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    logger.info('PARAMS %s' % repr(params))
    

    #Pelis
    """
    params = {
            'action': 'details',
            'category': '',
            'idm': '12654',
            'mediaType': '2',
            'channel': ''
        }
    """
    params = {'mediaType':params['mediaType'], 'idm':params['idm']}
    addfolder(name='Info (En desarrollo)', channelname=serialize(params), action='')
    addfolder(name='Trailer (En desarrollo)', channelname=serialize(params), action='')
    addfolder(name='Relacionadas (En desarrollo)', channelname=serialize(params), action='')
    addfolder(name='Criticas (En desarrollo)', channelname=serialize(params), action='')
    #addfolder(name='Cambiar estado', channelname=serialize(params), action='change_status')
    addfolder(name='Enlaces', channelname=serialize(params), action='links')

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def series_chapters(params, url, category):
    logger.info('channelselector.series_chapter')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    
    seasons = API.get_serie_info(id=params['id'], mediaType=params['mediaType'])
    #logger.info(repr(seasons))
    episodes = seasons['episodes'][params['season']]
    for episode in episodes:
        title = '%sx%s - %s' % (episode['season'], episode['episode'], 
                                episode['title'])
        if episode.has_key('viewed'):
            pass
            #title += ' |            Visto'
        params = {'idMedia':episode['idc'], 
                  'mediaType':episode['mediaType']}

        logger.info("EPISODE %s" % str(episode))
        if episode.has_key('viewed'):
            addfolder(name=title, channelname=serialize(params), action='links', watched=True)
        else:
            addfolder(name=title, channelname=serialize(params), action='links')

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def my_series(params, url, category):
    logger.info("channelselector.my_series")
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    series = API.my_series()
    for serie in series:
        logger.info(repr(serie))
        channelname = {'mediaType':serie['mediaType'], 'id':serie['id']} #Params to define a serie
        addfolder(name=serie['name'] , channelname=serialize(channelname) , action="serie_seasons",
            thumbnail=serie['image'])

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def show_links(params, url, category):
    logger.info('channelselector.show_links')
    logger.info('PARAMS: %s' % params)
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)

    try:
        del params['title'] #Prevent unicode/ascii problems
    except:
        pass

    if int(params['mediaType']) == api_sly.SERIE:
        logger.info("ENTRASERIE")
        links = API.get_links(idm=params['idMedia'], 
                          mediaType=params['mediaType'])
    elif int(params['mediaType']) == api_sly.MOVIE:
        links = API.get_links(idm=params['idm'], 
                          mediaType=params['mediaType'])

    count = 0
    if params.has_key('number'):
        count = int(params['number'])
        links = links[count:]

    for link in links:
        not_available = False
        url = ''
        
        if link['linksType'] == 'streaming':
            logger.info("LINK: %s" % repr(link))
            quality = link['quality']
            if link.has_key('features'):
                quality += ' ' + link['features']
            title = '%s | %s | %s' % (link['lang'], quality, link['host'])
            if not players_tools.available_player(link['host']):
                title += ' | Reproductor NO DISPONIBLE' 
            params['idVideo'] = link['idVideo']
            params['host'] = link['host']
            if not_available:
                title += ' | No disponible'
                addfolder(name=title, channelname=params, action=params['action'])
            else:
                addfolder(name=title, channelname=params, action='view_video')
   
    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def most_valuated_movies(params, url, category):
    #TODO Developing
    logger.info('channelselector.most_valuated_movies')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    
    movies = API.get_most_valuated(mediaType=api_sly.MOVIE)
    #logger.info("DATA %s" % repr(series))
    for media in movies:
        addfolder(name=media['name'], channelname=serialize(media), 
                  action='details', thumbnail=media['thumbnail'])

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def change_status(params, url, category):
    logger.info('channelselector.change_status')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    logger.info('PARAMS %s' % repr(params))
    if params.has_key('new_status'):
        params['status'] = params['new_status']
        logger.info("VIENE PARA CAMBIARLO")
        
        API.change_status(idm=params['idm'], 
                          mediaType=params['mediaType'], 
                          newStatus=params['new_status'])
        
        logger.info("newSTATUS: %s" % params['new_status'])
        """
        params = {
        'action': 'change_status', 
        'category': 'Cambiar estado', 
        'idm': '12481', 
        'mediaType': '2', 
        'channel': ''
        }
        """
    status = [1, 2, 3]
    #First, actual status
    params['new_status'] = params['status']
    title = '%s | Actual' % API.media_status(params['status'])
    addfolder(name=title, channelname=params, action='details')
    status.remove(int(params['status']))
    #Then, the rest
    for i in status:
        params['new_status'] = i
        addfolder(name=API.media_status(i), channelname=params, action='change_status')

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def view_video(params, url, category):
    logger.info('channelselector.view_video')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    logger.info("PARAMS: %s" % repr(params))
    url = ''
    if params['host'] == 'Played.to':
        url_host = API.get_video_link(idVideo=params['idVideo'], mediaType=params['mediaType'])
        logger.info("PLAYEDTO: %s" % url_host)
        url = PlayedTo.get_video_by_url(url_host)
        logger.info("PLAYEDTO2: %s" % url)
    elif params['host'] == 'allmyvideos':
        url_host = API.get_video_link(idVideo=params['idVideo'], mediaType=params['mediaType'])
        logger.info("ALLMYVIDEOS: %s" % url_host)
        url = Allmyvideos.get_video_by_url(url_host)
        logger.info("ALLMYVIDEOS2: %s" % url)
    elif params['host'] == 'Magnovideo':
        url_host = API.get_video_link(idVideo=params['idVideo'], mediaType=params['mediaType'])
        logger.info("MAGNOVIDEO: %s" % url_host)
        url = MagnoVideo.get_video_by_url(url_host)
        logger.info("MAGNOVIDEO2: %s" % url)
    elif params['host'] == 'Vidspot':
        url_host = API.get_video_link(idVideo=params['idVideo'], mediaType=params['mediaType'])
        logger.info("VIDSPOT: %s" % url_host)
        url = VidSpot.get_video_by_url(url_host)
        logger.info("VIDSPOT2: %s" % url)
    elif params['host'] == 'StreamCloud':
        url_host = API.get_video_link(idVideo=params['idVideo'], 
                                      mediaType=params['mediaType'])
        logger.info("StreamCloud: %s" % url_host)
        url = StreamCloud.get_video_by_url(url_host)
        logger.info("Streamcloud2: %s" % url)

    addvideo(name='Ver', url=url)
    params['report'] = 1
    #addfolder(name='Reportar', channelname=serialize(params), action='report')
    finish_video_list()
def my_movies(params, url, category):
    logger.info("channelselector.my_movies")
    API = api_sly.APISLY(username=config.get_setting('username'),
                     password=config.get_setting('password'), 
                     force=True)
    movies = API.my_movies()
    for movie in movies:
        logger.info(repr(movie))
        channelname = {'mediaType':movie['mediaType'], 
                        'idMedia':movie['id2'], 
                        'status':movie['status'],
                        'idm': movie['idm']} #Params to define a movie
        title = '%s [%s]' % (movie['name'], 
                             API.media_status(mediaType=movie['mediaType'], 
                                         status=movie['status']))
        addfolder(name=title,
                  channelname=serialize(channelname), 
                  action="details",
                  thumbnail=movie['image'])

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
Beispiel #10
0
def series_seasons(params, url, category):
    logger.info('channelselector.chapters')
    API = api_sly.APISLY(username=config.get_setting('username'),
                         password=config.get_setting('password'), 
                         force=True)
    #Needed mediaType and id_media
    logger.info(repr(params))
    #params = {'category': '', 'mN': 'The Big Bang Theory', 'id2': '589', 'nE': '169', 'mT': '1', 'action': 'serie_seasons', 'nS': '7', 'id': '2V675K5Y2R', 'channel': ''}
    
    seasons = API.get_serie_info(mediaType=params['mediaType'], id=params['id'])
    
    episodes = seasons['episodes']
    
    params = {'mediaType': params['mediaType'], 'id':params['id']}
    od = collections.OrderedDict(sorted(episodes.items()))
    for i in od.iterkeys():
        params['season'] = i
        addfolder(name="Temporada %s" % i, 
                  channelname=serialize(params), 
                  action='chapters')
    
    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
Beispiel #11
0
def mainlist(params,url,category):
    logger.info("channelselector.mainlist")
    if not config.is_configured():
        config.open_settings()

    now_in_channel = 'main'
    addfolder("Buscar" , 'main' , "search") # , thumbnailname=elemento.thumbnail, folder=elemento.folder)
    addfolder("Mis series" , 'main' , "my_series")
    addfolder("Mis pelis" , 'main' , "my_movies")
    addfolder('Series más vistas' , 'main' , 'most_valuated_series')
    addfolder('Pelis más vistas' , 'main' , 'most_valuated_movies')
    addfolder("Cerrar sesión (%s)" % config.get_setting('username'), 
                                                        'main' , 'logout')
    addfolder("Actualizar plugin" , 'main' , "update_plugin")
    addfolder("Configuración" , 'main' , "configuration")
    # Label (top-right)...

    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
Beispiel #12
0
# pelisalacarta
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
# Creado por: Jesús ([email protected])
# Licencia: GPL (http://www.gnu.org/licenses/gpl-3.0.html)
#------------------------------------------------------------
# Historial de cambios:
# Modified by plutec for adding loggeractive via config
#------------------------------------------------------------

import platformcode.xbmc.logger as platformlogger
default = False

from core import config2 as config

loggeractive = config.get_setting('debug')=='true'

def log_enable(active):
    global loggeractive
    loggeractive = active

def info(texto):
    if loggeractive:
        if not default:
            platformlogger.info(texto)
        else:
            print texto

def debug(texto):
    if loggeractive:
        if not default:
Beispiel #13
0
def run():
    logger.info("[launcher.py] run")
    
    # Test if all the required directories are created
    #config.verify_directories_created() #Innecesary for me
    
    # Extract parameters from sys.argv
    params, channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, category, show, password = extract_parameters()
    logger.info("[launcher.py] channel_name=%s, title=%s, fulltitle=%s, url=%s, thumbnail=%s, plot=%s, action=%s, server=%s, extra=%s, subtitle=%s, category=%s, show=%s, password=%s" % (channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, category, show, password))

    try:
        if action == 'selectchannel': #TODO REMOVE
            action = 'main'

        select_channel(action, channel_name, params, url, category)
        # Default action, select channel
        #FIN
        return
        if action == "selectchannel":
            select_channel2(params, url, category) #MIO

        # Actualizar version
        elif action == 'update':
            #update(params, url, category) #MIO
            pass
        elif action == 'search' and channel_name == 'main':
            logger.info("MIOOOOOOOOOOO")

        elif (action=="channeltypes"):
            import channelselector as plugin
            plugin.channeltypes(params,url,category)

        elif (action=="listchannels"):
            import channelselector as plugin
            plugin.listchannels(params,url,category)
       

        # El resto de acciones vienen en el parámetro "action", y el canal en el parámetro "channel"
        else:
            if action=="mainlist" and config.get_setting("updatechannels")=="true":
                update_channel(channel_name)

            # La acción puede estar en el core, o ser un canal regular. El buscador es un canal especial que está en pelisalacarta
            regular_channel_path = os.path.join( config.get_runtime_path(), PLUGIN_NAME , 'channels' , channel_name+".py" )
            core_channel_path = os.path.join( config.get_runtime_path(), 'core' , channel_name+".py" )
            logger.info("[launcher.py] regular_channel_path=%s" % regular_channel_path)
            logger.info("[launcher.py] core_channel_path=%s" % core_channel_path)

            if channel_name=="buscador":
                import pelisalacarta.buscador as channel
            elif os.path.exists( regular_channel_path ):
                exec "import "+PLUGIN_NAME+".channels."+channel_name+" as channel"
            elif os.path.exists( core_channel_path ):
                exec "from core import "+channel_name+" as channel"

            logger.info("[launcher.py] running channel %s %s" % (channel.__name__ , channel.__file__))

            generico = False
            # Esto lo he puesto asi porque el buscador puede ser generico o normal, esto estará asi hasta que todos los canales sean genericos 
            if category == "Buscador_Generico":
                generico = True
            else:
                try:
                    generico = channel.isGeneric()
                except:
                    generico = False

            if not generico:
                logger.info("[launcher.py] xbmc native channel")
                if (action=="strm"):
                    from platformcode.xbmc import xbmctools
                    xbmctools.playstrm(params, url, category)
                else:
                    exec "channel."+action+"(params, url, category)"
            else:            
                logger.info("[launcher.py] multiplatform channel")
                from core.item import Item
                item = Item(channel=channel_name, title=title , fulltitle=fulltitle, url=url, thumbnail=thumbnail , plot=plot , server=server, category=category, extra=extra, subtitle=subtitle, show=show, password=password)
                
                '''
                if item.subtitle!="":
                    logger.info("[launcher.py] Downloading subtitle file "+item.subtitle)
                    from core import downloadtools
                    
                    ficherosubtitulo = os.path.join( config.get_data_path() , "subtitulo.srt" )
                    if os.path.exists(ficherosubtitulo):
                        os.remove(ficherosubtitulo)

                    downloadtools.downloadfile(item.subtitle, ficherosubtitulo )
                    config.set_setting("subtitulo","true")
                else:
                    logger.info("[launcher.py] No subtitle")
                '''
                from platformcode.xbmc import xbmctools

                if action=="play":
                    logger.info("[launcher.py] play")
                    # Si el canal tiene una acción "play" tiene prioridad
                    if hasattr(channel, 'play'):
                        logger.info("[launcher.py] executing channel 'play' method")
                        itemlist = channel.play(item)
                        if len(itemlist)>0:
                            item = itemlist[0]
                            xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=item.fulltitle)
                        else:
                            import xbmcgui
                            ventana_error = xbmcgui.Dialog()
                            ok = ventana_error.ok ("plugin", "No hay nada para reproducir")
                    else:
                        logger.info("[launcher.py] no channel 'play' method, executing core method")
                        xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=item.fulltitle)

                elif action=="strm_detail" or action=="play_from_library":
                    logger.info("[launcher.py] play_from_library")

                    fulltitle = item.show + " " + item.title
                    elegido = Item(url="")                    

                    logger.info("item.server=#"+item.server+"#")
                    # Ejecuta find_videos, del canal o común
                    try:
                        itemlist = channel.findvideos(item)
                    except:
                        from servers import servertools
                        itemlist = servertools.find_video_items(item)

                    if len(itemlist)>0:
                        #for item2 in itemlist:
                        #    logger.info(item2.title+" "+item2.subtitle)
    
                        # El usuario elige el mirror
                        opciones = []
                        for item in itemlist:
                            opciones.append(item.title)
                    
                        import xbmcgui
                        dia = xbmcgui.Dialog()
                        seleccion = dia.select(config.get_localized_string(30163), opciones)
                        elegido = itemlist[seleccion]
    
                        if seleccion==-1:
                            return
                    else:
                        elegido = item
                
                    # Ejecuta el método play del canal, si lo hay
                    try:
                        itemlist = channel.play(elegido)
                        item = itemlist[0]
                    except:
                        item = elegido
                    logger.info("Elegido %s (sub %s)" % (item.title,item.subtitle))
                    
                    from platformcode.xbmc import xbmctools
                    logger.info("subtitle="+item.subtitle)
                    xbmctools.play_video(strmfile=True, channel=item.channel, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=fulltitle)

                elif action=="add_pelicula_to_library":
                    logger.info("[launcher.py] add_pelicula_to_library")
                    from platformcode.xbmc import library
                    # Obtiene el listado desde el que se llamó
                    library.savelibrary( titulo=item.fulltitle , url=item.url , thumbnail=item.thumbnail , server=item.server , plot=item.plot , canal=item.channel , category="Cine" , Serie=item.show.strip() , verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle )

                elif action=="add_serie_to_library":
                    logger.info("[launcher.py] add_serie_to_library")
                    from platformcode.xbmc import library
                    import xbmcgui
                
                    # Obtiene el listado desde el que se llamó
                    action = item.extra
                    exec "itemlist = channel."+action+"(item)"

                    # Progreso
                    pDialog = xbmcgui.DialogProgress()
                    ret = pDialog.create('pelisalacarta', 'Añadiendo episodios...')
                    pDialog.update(0, 'Añadiendo episodio...')
                    totalepisodes = len(itemlist)
                    logger.info ("[launcher.py] Total Episodios:"+str(totalepisodes))
                    i = 0
                    errores = 0
                    nuevos = 0
                    for item in itemlist:
                        i = i + 1
                        pDialog.update(i*100/totalepisodes, 'Añadiendo episodio...',item.title)
                        if (pDialog.iscanceled()):
                            return
                
                        try:
                            #(titulo="",url="",thumbnail="",server="",plot="",canal="",category="Cine",Serie="",verbose=True,accion="strm",pedirnombre=True):
                            # Añade todos menos el último (el que dice "Añadir esta serie...")
                            if i<len(itemlist):
                                nuevos = nuevos + library.savelibrary( titulo=item.title , url=item.url , thumbnail=item.thumbnail , server=item.server , plot=item.plot , canal=item.channel , category="Series" , Serie=item.show.strip() , verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle )
                        except IOError:
                            import sys
                            for line in sys.exc_info():
                                logger.error( "%s" % line )
                            logger.info("[launcher.py]Error al grabar el archivo "+item.title)
                            errores = errores + 1
                        
                    pDialog.close()
                    
                    # Actualizacion de la biblioteca
                    itemlist=[]
                    if errores > 0:
                        itemlist.append(Item(title="ERROR, la serie NO se ha añadido a la biblioteca o lo ha hecho incompleta"))
                        logger.info ("[launcher.py] No se pudo añadir "+str(errores)+" episodios")
                    else:
                        itemlist.append(Item(title="La serie se ha añadido a la biblioteca"))
                        logger.info ("[launcher.py] Ningún error al añadir "+str(errores)+" episodios")
                    
                    # FIXME:jesus Comentado porque no funciona bien en todas las versiones de XBMC
                    #library.update(totalepisodes,errores,nuevos)
                    xbmctools.renderItems(itemlist, params, url, category)
                    
                    #Lista con series para actualizar
                    nombre_fichero_config_canal = os.path.join( config.get_data_path() , "series.xml" )
                    logger.info("nombre_fichero_config_canal="+nombre_fichero_config_canal)
                    if not os.path.exists(nombre_fichero_config_canal):
                        f = open( nombre_fichero_config_canal , "w" )
                    else:
                        f = open( nombre_fichero_config_canal , "r" )
                        contenido = f.read()
                        f.close()
                        f = open( nombre_fichero_config_canal , "w" )
                        f.write(contenido)
                    f.write(item.show+","+item.url+","+item.channel+"\n")
                    f.close();

                elif action=="download_all_episodes":
                    download_all_episodes(item,channel)

                elif action=="search":
                    logger.info("[launcher.py] search")
                    import xbmc
                    keyboard = xbmc.Keyboard("")
                    keyboard.doModal()
                    if (keyboard.isConfirmed()):
                        tecleado = keyboard.getText()
                        tecleado = tecleado.replace(" ", "+")
                        itemlist = channel.search(item,tecleado)
                    else:
                        itemlist = []
                    xbmctools.renderItems(itemlist, params, url, category)

                else:
                    logger.info("[launcher.py] executing channel '"+action+"' method")
                    if action!="findvideos":
                        exec "itemlist = channel."+action+"(item)"
                    else:
                        # Intenta ejecutar una posible funcion "findvideos" del canal
                        try:
                            exec "itemlist = channel."+action+"(item)"
                        # Si no funciona, lanza el método genérico para detectar vídeos
                        except:
                            logger.info("[launcher.py] no channel 'findvideos' method, executing core method")
                            from servers import servertools
                            itemlist = servertools.find_video_items(item)
                        from core import subtitletools
                        subtitletools.saveSubtitleName(item)

                    # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento
                    import xbmcplugin
                    import sys
                    handle = sys.argv[1]
                    xbmcplugin.setContent(int( handle ),"movies")
                    
                    # Añade los items a la lista de XBMC
                    xbmctools.renderItems(itemlist, params, url, category)

    except urllib2.URLError,e:
        import traceback
        import sys
        from pprint import pprint
        exc_type, exc_value, exc_tb = sys.exc_info()
        lines = traceback.format_exception(exc_type, exc_value, exc_tb)
        for line in lines:
            line_splits = line.split("\n")
            for line_split in line_splits:
                logger.error(line_split)
        import xbmcgui
        ventana_error = xbmcgui.Dialog()
        # Agarra los errores surgidos localmente enviados por las librerias internas
        if hasattr(e, 'reason'):
            logger.info("Razon del error, codigo: %d , Razon: %s" %(e.reason[0],e.reason[1]))
            texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web"
            ok = ventana_error.ok ("plugin", texto)
        # Agarra los errores con codigo de respuesta del servidor externo solicitado     
        elif hasattr(e,'code'):
            logger.info("codigo de error HTTP : %d" %e.code)
            texto = (config.get_localized_string(30051) % e.code) # "El sitio web no funciona correctamente (error http %d)"
            ok = ventana_error.ok ("plugin", texto)