Example #1
0
def filtar_paisTendencia(mapCountry, country):
    pais= mp.get(mapCountry,country)
    lst_videos = me.getValue(pais)
    new_list =  lt.newList(datastructure= 'ARRAY_LIST')
    for video in lt.iterator(lst_videos):
        if video['country'] == country:
            lt.addLast(new_list,video)
    videosByFreq = añadir_frecuencia(new_list)
    videosSorted = sortVideos(videosByFreq,cmpVideosByFreq)
    video_rta = alt.firstElement(videosSorted)
    return filtrar_req2(video_rta)
Example #2
0
def video_mas_dias_tendencia(mapCategory,category):
    categoria = mp.get(mapCategory,category)
    valueCat = me.getValue(categoria)
    lst_videos = valueCat['videos']
    new_list = lt.newList(datastructure='ARRAY_LIST')
    for video in lt.iterator(lst_videos):
        if (video['video_id']!= '#NAME?'):
            lt.addLast(new_list,video)
    videosByFreq = añadir_frecuencia(new_list)
    videosSorted = sortVideos(videosByFreq,cmpVideosByFreq)
    video_rta = alt.firstElement(videosSorted)
    return filtrar_req3(video_rta)
def firstElement(lst):
    """ Retorna el primer elemento de una lista no vacía.
        No se elimina el elemento.

    Args:
        lst: La lista a examinar

    Raises:
        Exception
    """
    try:
        if (lst['type'] == 'ARRAY_LIST'):
            return alt.firstElement(lst)
        else:
            return slt.firstElement(lst)
    except Exception as exp:
        error.reraise(exp, 'List->firstElement: ')
Example #4
0
def getfirst(catalog):
    elemento = array.firstElement(catalog["videos"])
    return elemento
Example #5
0
catalog = None
"""
Menu principal
"""
while True:
    printMenu()
    inputs = input('Seleccione una opción para continuar\n')
    if int(inputs[0]) == 1:
        print("Cargando información de los archivos ...")
        catalog = initCatalog()
        t1 = t.process_time()
        loadData(catalog)
        t2 = t.process_time()
        print("Tiempo: {:} s".format(t2 - t1))
        print('Videos cargados: ' + str(lt.size(catalog['videos'])))
        fv = al.firstElement(catalog['videos'])
        print('Primer video: ' + str(fv['title']) + ', ' +
              str(fv['cannel_title']) + ', ' + str(fv['trending_date']) +
              ', ' + str(fv['country']) + ', views: ' + str(fv['views']) +
              ', likes: ' + str(fv['likes']) + ', dislikes: ' +
              str(fv['dislikes']))
        print(catalog['video_category_id'])

    elif int(inputs[0]) == 2:
        cant_vd = int(input('Ingrese el tamaño del ranking: '))
        country = str(input('Ingrese el país de los videos a analizar: '))
        category = str(
            input('Ingresa la categoria de los videos a analizar: '))
        id_category = int(controller.category_id_name(catalog, category))
        print(controller.load_Req_1(catalog, country, id_category, cant_vd))