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 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)
"elementos, el tiempo (mseg) es:", str(resultado[0])) print("\n") printResults(resultado[1], int(n)) else: print("\n") print("No se encontró la Categoría") else: print("\n") 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)
size = input("Indique tamaño de la muestra: ") result = controller.sortVideos(catalog, int(size), ordenamiento) print("Para la muestra de", size, " elementos, el tiempo (mseg) es: ", str(result[0])) elif int(inputs[0]) == 3: 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)
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) else: sys.exit(0) sys.exit(0)
print('Videos cargados: ' + str(lt.size(catalog['videos']))) elif int(inputs[0]) == 2: number = input("Buscando los TOP ?: ") input_sort_type = 'merge' sortedVideos = controller.sortVideos(catalog, int(number), str(input_sort_type)) printTop(sortedVideos[1], int(number)) elif int(inputs[0]) == 3: number = input("Buscando los TOP ?: ") category = input('Categoria: ') country = input('País: ') input_sort_type = 'merge' categoryVideos = controller.getVideosByCategory(catalog, category) countryVideos = controller.getVideosByCountry(categoryVideos, country) sortedVideos = controller.sortVideos(countryVideos, int(number), str(input_sort_type)) printCategoryCountry(sortedVideos[1], number, category, country) elif int(inputs[0]) == 4: country = input('País: ') input_sort_type = 'merge' countryVideos = controller.getVideosByCountry(catalog, country) sortedVideosTime = controller.sortVideosTime(countryVideos, int(1), str(input_sort_type)) printTopTrendingCountry(sortedVideosTime[1], int(number)) elif int(inputs[0]) == 5: category = input('Categoria: ') input_sort_type = 'merge'
# INICIO # respuesta por defecto books = None delta_time = -1.0 delta_memory = -1.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)
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) result = controller.getMostTrendingDaysByID( videos_filtrados.get('videos')) printResultsv3(result) elif str(inputs[0]) == "6": pais = input("Ingrese el país de referencia: ")