Ejemplo n.º 1
0
        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)
Ejemplo n.º 2
0
    elif int(inputs[0]) == 4:
        categoryname = str(input("Ingrese la categoría\n"))
        categoryid = controller.getCategoryId(catalog, categoryname)
        videos = controller.getVideosByCategory(catalog, categoryid)
        sortedVideos = controller.sortVideosById(videos[0])
        firstVideoByTrendingDays = controller.getFirstVideoByTrendingDays(
            sortedVideos[0])
        time = videos[1] + sortedVideos[1] + firstVideoByTrendingDays[1]
        memory = videos[2] + sortedVideos[2] + firstVideoByTrendingDays[2]
        printFirstVideoByTrendingDaysByCategory(firstVideoByTrendingDays[0],
                                                categoryid, categoryname)
        printTimeandMemory(time, memory)

    elif int(inputs[0]) == 5:
        country = str(input("Ingrese el país\n"))
        tag = str(input("Ingrese el tag\n"))
        size = int(input("Ingrese el número de videos a listar\n"))
        videos = controller.getVideosByCountryAndTag(catalog, country, tag)
        sortedVideos = controller.sortVideosByLikes(videos[0])
        time = videos[1] + sortedVideos[1]
        memory = videos[2] + sortedVideos[2]
        if size > lt.size(videos[0]):
            print("El número de videos excede el tamaño del catálogo\n")
        else:
            printSortedVideosByLikes(sortedVideos[0], size, country, tag)
            printTimeandMemory(time, memory)

    else:
        sys.exit(0)
sys.exit(0)
Ejemplo n.º 3
0
def sortVideosByLikes(catalog, size):
    """
    Organiza los videos mediante Merge Sort
    """
    return controller.sortVideosByLikes(catalog, size)
Ejemplo n.º 4
0
 start_time = controller.getTime()
 start_memory = controller.getMemory()
 # toma de tiempo y memoria
 tag_name = input("Ingrese el nombre del 'tag': ").lower()
 country_name = input("Ingrese el nombre del pais: ").title()
 n_videos = int(input("Ingrese el numero top de videos que desea: "))
 videosByCountry = controller.getVidsByCountry(catalog, country_name)
 if videosByCountry is None:
     print(f"El pais {country_name} no se encontró")
 else:
     videosByTag = controller.getVidsByTag(videosByCountry, tag_name)
     if videosByTag is None:
         print(f"El tag {tag_name} no se encontró en la lista del pais")
     else:
         videosUniques = controller.videoUniques(videosByTag)
         videosByLikes = controller.sortVideosByLikes(videosUniques)
         counter = 1
         while counter <= n_videos:
             video = lt.getElement(videosByLikes, counter)
             print("#" + str(counter), 'title: ' + video['title'], '\n',
                   'channel_title: ' + video['channel_title'], '\n',
                   'publish_time: ' + video['publish_time'], '\n',
                   'views: ' + video['views'], '\n',
                   'likes: ' + video['likes'], '\n',
                   'dislikes: ' + video['dislikes'], '\n',
                   'tags: ' + video['tags'] + '\n')
             counter += 1
 print("\n")
 # toma de tiempo y memoria
 stop_memory = controller.getMemory()
 stop_time = controller.getTime()
Ejemplo n.º 5
0
    printMenu()
    inputs = input('Seleccione una opción para continuar\n')
    if int(inputs[0]) == 1:
        print("Cargando información de los archivos ....")
        catalog = initCatalog()
        answer = loadData(catalog)
        print('Videos cargados: ' + str(lt.size(catalog['video'])))
        print('Categorias cargadas: ' + str(lt.size(catalog['categoryID'])))
        print("\nTiempo [ms]: ", f"{answer[0]:.3f}", "  ||  ",
              "Memoria [kB]: ", f"{answer[1]:.3f}\n")

    elif int(inputs[0]) == 2:
        categoria = input("Seleccione una categoria: ")
        top = input('¿Top?: ')
        categoryID = controller.getCategoryid(catalog, categoria)
        lista = controller.sortVideosByLikes(catalog, categoryID)
        printVideosByLikes(lista, int(top))

    elif int(inputs[0]) == 3:
        categoria = input("Seleccione una categoria: ")
        pais = input("Seleccione un pais: ")
        top = input('¿Top?: ')
        categoryID = controller.getCategoryid(catalog, categoria)
        lista = controller.sortVideosByViews(catalog, pais)
        masVistos = controller.sublistByCategory(lista, categoryID, top)
        printVideosByViews(masVistos, int(top))

    elif int(inputs[0]) == 4:
        pais = input("Seleccione un pais: ")
        video = controller.mostDaysByCountry(catalog, pais)
        printTendencyByCountry(video)