Beispiel #1
0
def categorias(item):
    logger.info("m3uchannel.categorias")

    itemlist = []

    # Si es una URL la descarga
    if item.url.startswith("http://") or item.url.startswith("https://"):
        data = scrapertools.cache_page(item.url)

    # Si es un fichero local, lo abre
    else:
        infile = open(item.url)
        data = infile.read()
        infile.close()

    # Parsea la lista
    categories = m3utools.parse_categories_from_m3u_list(data)

    for category in categories:
        itemlist.append(
            Item(channel=__channel__,
                 title=category.title,
                 action="entradas",
                 url=item.url,
                 folder=True))

    return itemlist
Beispiel #2
0
def categorias(item, data=""):
    logger.info("simpletv.categorias")

    itemlist = []

    # Obtiene la lista de categorias a partir del m3u
    recursividad_permitida = False
    if data == "":
        recursividad_permitida = True
        data = get_online_list()
        categories = m3utools.parse_categories_from_m3u_list(data)

    # Si ha encontrado canales, graba el fichero actualizado por si en el futuro falla
    if len(categories) > 0:
        f = open(LOCAL_FILE, "w")
        f.write(data)
        f.flush()
        f.close()

    # Si no ha encontrado canales, lee el fichero grabado la última vez y carga de nuevo la lista
    elif recursividad_permitida:
        infile = open(LOCAL_FILE, "r")
        data = infile.read()
        infile.close()
        itemlist = categorias(item, data)

    for category in categories:
        itemlist.append(
            Item(channel=__channel__,
                 title=category.title,
                 action="entradas",
                 folder=True))

    return itemlist
Beispiel #3
0
def categorias(item,data=""):
    logger.info("simpletv.categorias")

    itemlist = []

    # Obtiene la lista de categorias a partir del m3u
    recursividad_permitida = False
    if data=="":
        recursividad_permitida = True
        data = get_online_list()
        categories = m3utools.parse_categories_from_m3u_list(data)

    # Si ha encontrado canales, graba el fichero actualizado por si en el futuro falla
    if len(categories)>0:
        f = open(LOCAL_FILE,"w")
        f.write(data)
        f.flush()
        f.close()

    # Si no ha encontrado canales, lee el fichero grabado la última vez y carga de nuevo la lista
    elif recursividad_permitida:
        infile = open(LOCAL_FILE,"r")
        data = infile.read()
        infile.close()
        itemlist = categorias(item,data)

    for category in categories:
        itemlist.append( Item(channel=__channel__, title=category.title, action="entradas", folder=True) )

    return itemlist
Beispiel #4
0
def categorias(item):
    logger.info("m3uchannel.categorias")

    itemlist = []

    # Si es una URL la descarga
    if item.url.startswith("http://") or item.url.startswith("https://"):
        data = scrapertools.cache_page(item.url)

    # Si es un fichero local, lo abre
    else:
        infile = open( item.url )
        data = infile.read()
        infile.close()

    # Parsea la lista
    categories = m3utools.parse_categories_from_m3u_list(data)

    for category in categories:
        itemlist.append( Item(channel=__channel__, title=category.title, action="entradas", url=item.url , folder=True) )

    return itemlist