Exemplo n.º 1
0
    printMenu()
    inputs = input('Seleccione una opción para continuar\n')
    if int(inputs[0]) == 1:
        cont = controller.initCatalog()
        delta_t, delta_m = controller.loadData(cont)
        print("Cargando información de los archivos ....")
        print('Videos cargados: ' + str(controller.videosSize(cont)))
        print('Categorias cargadas: ' + str(controller.categoriesSize(cont)))
        print('Tiempo [ms]: ', f'{delta_t:.3f}', '  ||  ', 'Memoria [kB]: ',
              f'{delta_m:.3f}')

    elif int(inputs[0]) == 2:
        n_videos = input('Top videos por views: ')
        category = input('Categoría: ')
        country = input('Pais: ')
        videosCategoryCountry = controller.getVideosByCategoryAndCountry(
            cont, category, country)
        topVideosViews = controller.sortVideosViews(
            videosCategoryCountry['videos'], int(n_videos))
        printTopLikes(topVideosViews, int(n_videos))

    elif int(inputs[0]) == 3:
        country = input('Pais: ')
        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
        answer = controller.loadData(catalog)
        print("Categorias cargadas: " + str(lt.size(catalog['category'])))
        print("Videos cargados: " + str(lt.size(catalog['videos'])))
        # title, cannel_title, trending_date, country, views, likes, dislikes
        print("CATEGORIAS", end="\n\n")
        print(catalog['category'], end="\n\n")
        print("PRIMER VIDEO:", end="\n\n")
        print(lt.getElement(catalog["videos"], 1))
        print("Tiempo [ms]: ", f"{answer[0]:.3f}", "  ||  ", "Memoria [kB]: ",
              f"{answer[1]:.3f}")

    elif int(inputs[0]) == 2:
        country = input("Ingrese el país: ")
        category = input("Ingrese la categoria: ")
        number = int(input("cantidad de videos por listar: "))
        compilation = controller.getVideosByCategoryAndCountry(
            catalog, str(category), str(country), int(number))
        GoodVideosByCategoryAndConuntry(compilation[0])
        print("Tiempo [ms]: ", f"{compilation[1]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{compilation[2]:.3f}")

    elif int(inputs[0]) == 3:
        country = input("Ingrese el país: ")
        mosttrend = controller.FindTrendVideoByCountry(catalog, country)
        TrendByCountry(mosttrend[0])
        print("Tiempo [ms]: ", f"{mosttrend[1]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{mosttrend[2]:.3f}")

    elif int(inputs[0]) == 4:
        category = input("Ingrese la categoria: ")
        mosttrend = controller.FindTrendVideoByCategory(catalog, category)
        TrendByCategory(mosttrend[0])
Exemplo n.º 3
0
        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])
        print("Tiempo [ms]: ", f"{video[1][0]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{video[1][1]:.3f}")

    elif int(inputs[0]) == 3:
        category = input('Digite la categoria del video que busca: ')
        video = controller.getVideoByTrendingAndCategory(catalog,category)
        printResults3(video[0])
Exemplo n.º 4
0
        print('\n')
        loaded_categories = controller.categoriesSize(x)
        print('Categorías cargadas: ' + str(loaded_categories))
        print_table(x)
        print('\n')
        loaded_countries = controller.countriesSize(x)
        print('Países cargados: ' + str(controller.countriesSize(x)))
        print_list(x)

    elif str(inputs[0]) == "3":
        pais = input("\nIngrese el país de referencia: ")
        categoria = int(
            input('Ingrese el código la categoría de referencia: '))
        n = input("Ingrese el número de videos que desea imprimir: ")
        print("\nCargando ....")
        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)