示例#1
0
    Inicializa el catalogo de videos
    """
    return controller.initCatalog(tipo)


def loadData(catalog):
    """
    Carga los videos en la estructura de datos
    """
    controller.loadData(catalog)


"""
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 ....")

    elif int(inputs[0]) == 2:
        label = input("Categoria a buscar: ")
        n = int(input("Ingrese el n: "))
        videos = controller.getVideosByCategory(cont, label, n)
    elif int(inputs[0]) == 0:
        menu = Fals
    else:
        sys.exit(0)
sys.exit(0)
示例#2
0
        videosCountry = controller.getVideosByCountry(cont, country)
        topTrendingVideo = controller.sortVideosTime(videosCountry['videos'],
                                                     100)
        topVidTD = datetime.datetime.strptime(
            lt.getElement(topTrendingVideo, 0)['trending_date'], '%y.%d.%m')
        topVidPT = datetime.datetime.strptime(
            lt.getElement(topTrendingVideo, 0)['publish_time'][:10],
            '%Y-%m-%d')
        daysTrending = topVidTD - topVidPT
        daysTrending = int(daysTrending.days)
        printTopTrendingCountry(lt.getElement(topTrendingVideo, 0), 1,
                                daysTrending)

    elif int(inputs[0]) == 4:
        category = input('Categoría: ')
        videosCategory = controller.getVideosByCategory(cont, category)
        topTrendingVideo = controller.sortVideosTime(videosCategory['videos'],
                                                     100)
        topVidTD = datetime.datetime.strptime(
            lt.getElement(topTrendingVideo, 0)['trending_date'], '%y.%d.%m')
        topVidPT = datetime.datetime.strptime(
            lt.getElement(topTrendingVideo, 0)['publish_time'][:10],
            '%Y-%m-%d')
        daysTrending = topVidTD - topVidPT
        daysTrending = int(daysTrending.days)
        printTopTrendingCategory(lt.getElement(topTrendingVideo, 0), 1,
                                 daysTrending)

    elif int(inputs[0]) == 5:
        n_videos = input('Top videos por likes: ')
        tag = input('Tag: ')
示例#3
0
            print("No se encontró el país")

    elif str(inputs[0]) == "3":
        pais = input("Ingrese el país de referencia: ")
        print("\nCargando ....")
        lista = controller.getVideosByCountry(catalog['country'], pais)
        result = controller.sortVideos(
            lista, lt.size(lista), 'ms', 'comparetitles')[1]
        dias_tendencia = controller.getMostTrendingDays(result)
        print("\n")
        printResultsv3(dias_tendencia)

    elif str(inputs[0]) == "4":
        categoria = int(input('Ingrese la categoría de referencia: '))
        print("\nCargando ....")
        result1 = controller.getVideosByCategory(
            catalog['video'], categoria)
        result = controller.sortVideos(
            result1, lt.size(result1), 'ms', 'comparetitles')[1]

        video_tendencia = controller.getMostTrendingDays(result)
        print("\n")
        printResultsv3(video_tendencia)

    elif str(inputs[0]) == "5":
        pais = input("Ingrese el país de referencia: ")
        tag = input('Ingrese el tag de referencia: ')
        n = int(input("Ingrese el número de videos que desea imprimir: "))
        print("\nCargando ....")

        result = controller.getVideosByCountryAndTag(
             catalog['country'], tag, pais)
示例#4
0
Menu principal
"""
while True:
    printMenu()
    inputs = input('Seleccione una opción para continuar\n')
    if int(inputs[0]) == 9:
        print("Cargando información de los archivos ....")
        catalog = controller.initCatalog()
        answer = controller.loadData(catalog)
        print("Tiempo [ms]: ", f"{answer[0]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{answer[1]:.3f}")

    elif int(inputs[0]) == 8:
        n = input('Cuantos videos desea listar: ')
        category = input('Digite el nombre de la categoria: ')
        videos = controller.getVideosByCategory(catalog,category)
        printResults(videos,int(n))

    elif int(inputs[0]) == 1:
        n = input('Cuantos videos desea listar: ')
        category = input('Digite el nombre de la categoria: ')
        country = input('Digite el pais que desea listar: ')
        videos = controller.getVideosByCategoryAndCountry(catalog,category,country)
        printResults1(videos[0],int(n))
        print("Tiempo [ms]: ", f"{videos[1][0]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{videos[1][1]:.3f}")
    
    elif int(inputs[0]) == 2:
        country = input('Digite el pais del video que busca: ')
        video = controller.getVideoByTrendingAndCountry(catalog,country)
        printResults2(video[0])
示例#5
0
        country = input("Ingrese el país a consultar: ")
        category_name = input("Ingrese la categoría a consultar: ")
        n = input("Ingrese el número de videos que quiere listar: ")
        video = controller.getTrendingVideos(catalog, category_name, country,
                                             n)
        printTrendingVideos(video)

    elif int(inputs[0]) == 4:
        countryname = input("Nombre del país: ")
        country = controller.getVideosByCountry(catalog, countryname)
        if country == None:
            print("No se encontraron videos")
        else:
            printCountryData(country[0], country[1], countryname)

    elif int(inputs[0]) == 5:
        category_name = input("Ingrese la categoría: ")
        category = controller.getVideosByCategory(catalog, category_name)
        printCategoryData(category)

    elif int(inputs[0]) == 6:
        tag = input("Ingrese el tag a consultar: ")
        countryname = input("Nombre del país: ")
        n = int(input("Ingrese el número de videos que quiere listar: "))
        mas_likes = controller.getVideosByLikes(catalog, n, countryname, tag)
        printTagData(mas_likes)

    else:
        sys.exit(0)
sys.exit(0)
示例#6
0
        #TODO Requerimiento estudiante A
        pass

    elif int(inputs[0]) == 5:
        category = input("Sobre que catergoría desea buscar: ")
        categoryNumber = (controller.getCategory(catalog,category.lower().strip()))
        """
        Crea una lista de videos a partir el mapa que categoriza los videos por id y cuenta sus repeticiones

        Luego crea un mapa donde las llaves son los paises y las categorias y los valores son las listas con los videos

        Luego extrae esa lista y la ordena para luego imprimir el primero
        """
        idList = controller.createCategoryList(catalog)
        mapidList = controller.createCategoryMap(catalog, idList)
        categoryList = controller.getVideosByCategory(catalog, categoryNumber)
        answer = controller.sortVideosByTrending(categoryList, 1)
        controller.printReqThree(answer)

    elif int(inputs[0]) == 6:
        # REQUERIMIENTO 4
        country = input("Sobre que país desea buscar: ")
        tag = (input("Bajo que tag desea filtrar los videos: ")).strip().lower()
        rank = int(input("Ingrese la cantidad de videos para el top de vistas: "))
        
        countryList = controller.getVideosByCountry(catalog, country)
        filteredByTag = controller.filterByTag(countryList, tag)
        uniqueCountry = controller.createUniqueCountry(filteredByTag)
        sortedList = controller.sortVideosByLikes(uniqueCountry, rank)
        controller.printReqFour(sortedList)
示例#7
0
        cont = controller.initCatalog('PROBING', 0.5)
        answer = controller.loadData(cont)
        print('Videos cargados: ' + str(controller.videosSize(cont)))
        print('Categorías de los videos: ' + str(controller.categoriesSize(cont)))
        print('Paises de los videos: ' + str(controller.countriesSize(cont)))
        print('Categorías cargadas: ' + str(controller.categoriesListSize(cont)))

    elif int(inputs[0]) == 2:
        #req 1
        size=0
        category_name = input("Indique la categoría de los videos a consultar: ")
        country = input("Indique el país de los videos a consultar: ")
        id=controller.getIDbyCategoryName(cont, category_name)

        videosByCat=controller.getVideosByCategory(cont, id)

        filteredList=controller.filterVideos(videosByCat, ['country'],[country])

        while size<1 or size>lt.size(filteredList['videos']):
            size = int(input("Indique el número de videos a listar: "))

        print("Ordenando datos...\n")
        result = controller.sortVideos(filteredList, size, 'views')

        print('Videos top {} para {} bajo la categoría {}:\n'.format(size,country,category_name))

        print("trending_date | title | channel_title | publish_time | views | likes | dislikes")
        for i in lt.iterator(result):
            print(i['trending_date'],'|',i['title'],'|',i['channel_title'],'|',
            i['publish_time'],'|',i['views'],'|',i['likes'],'|',i['dislikes'])
                print("Por favor ingresa un pais disponible.")
        print('Cargando informacion, por favor espera...')
        time_1 = time.process_time()
        mas_trending = controller.getMostTrending(catalog, pais)
        time_2 = time.process_time()
        print("El video con mayor cantidad de dias en tendencia en {} es : ".
              format(pais))
        print("Titulo: " + mas_trending["title"] + ", Canal: " + mas_trending["channel_title"] + ", Dias en tendencia: "\
 + str(mas_trending["repeticiones"]) + ", Pais: " + mas_trending["country"])
        print('Milisegundos de carga :{}'.format(str(
            (time_2 - time_1) * 1000)))
#        print(mas_trending['video_id'])

    elif int(inputs[0]) == 4:
        categoria = input("Digite el nombre de la categoría que desea buscar")
        categoryCatalog = controller.getVideosByCategory(
            catalog, categoria, catalog)
        video = controller.masDiasTrending(catalog)
        print(
            "El vídeo con más días de tendencia en la categoría {0} fue: Nombre: {1} -- Canal: {2} -- ID de la Categoría: {3} -- Días en Trending: {4}"
            .format(categoryName, video['title'], video['channel_title'],
                    video['category_id'], video['dias_t']))

    elif int(inputs[0]) == 5:
        n = lt.size(catalog['videos'])
        print("Buscando en el país: ")
        ha_escogido_pais = False
        while not ha_escogido_pais:
            pais = input("")
            if controller.pais_presente(catalog, pais):
                ha_escogido_pais = True
            else:
示例#9
0
        # inicializa el processo para medir memoria
        tracemalloc.start()

        # toma de tiempo y memoria al inicio del proceso
        start_time = getTime()
        start_memory = getMemory()
        # FIN

        countryCatalog = controller.getVideosByCountry(
            catalog, countryName)  # Nuevo catálogo filtrado del país elegido
        printCountryData(countryCatalog)

        # Inputs secundarios del usuario

        categoryCatalog = controller.getVideosByCategory(
            countryCatalog, categoryName, catalog)  # Mirar parámetros

        printCategoryData(
            categoryCatalog
        )  # Se imprime la información filtrada por categoría y país

        result = controller.sortVideos(categoryCatalog,
                                       1)  # Ordenamiento por views

        printResults(result, sample=cantidad_videos)

        # INICIO
        # toma de tiempo y memoria al final del proceso
        stop_memory = getMemory()
        stop_time = getTime()
示例#10
0
        result = controller.getVideosByCategoryAndCountry(x, categoria, pais)
        printResults(result[1], int(n))

    elif str(inputs[0]) == "4":
        pais = input("Ingrese el país de referencia: ")
        print("\nCargando ....")
        videos_filtrados = controller.getVideosByCountry(x, pais)
        result = controller.getMostTrendingDaysByID(
            videos_filtrados.get('videos'))
        printResultsv3(result)

    elif str(inputs[0]) == "5":
        categoria = int(
            input('Ingrese el código la categoría de referencia: '))
        print("\nCargando ....")
        videos_filtrados = controller.getVideosByCategory(x, categoria)
        result = controller.getMostTrendingDaysByID(
            videos_filtrados.get('videos'))
        printResultsv3(result)

    elif str(inputs[0]) == "6":
        pais = input("Ingrese el país de referencia: ")
        tag = input('Ingrese el tag de referencia: ')
        n = int(input("Ingrese el número de videos que desea imprimir: "))
        print("\nCargando ....")

        result = controller.getVideosByCountryAndTag(x, tag, pais)

        print("Para la muestra de", lt.size(x['country']),
              "elementos, el tiempo (mseg) es:", str(result[0]))