def filtrar_PaisCategoria(catalog, country, category, size): videos = catalog['videos'] sub_list = lt.newList(datastructure='ARRAY_LIST') for video in lt.iterator(videos): if video['country'] == country and video['category_id'] == category: al.addLast(sub_list, video) sorted_list = sortVideos(sub_list, cmpVideosByViews) lst_n = lt.subList(sorted_list, 1, size) return filtrar_datos_req1(lst_n)
def filtrar_PaisCategoria(mapCategory,category,country,size): 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['country']==country: alt.addLast(new_list,video) sorted_list= sortVideos(new_list,cmpVideosByViews) lst_n = lt.subList(sorted_list,1,size) return lst_n
def añadir_frecuencia(lst): new_list = lt.newList(datastructure='ARRAY_LIST') dic_list = lt.newList(datastructure='ARRAY_LIST') for video in lt.iterator(lst): if alt.isPresent(new_list,video['video_id']): for dic in lt.iterator(dic_list): if dic['id'] == video['video_id']: dic['freq'] += 1 else: dic={'id': video['video_id'], 'freq': 1, 'video': video} alt.addLast(dic_list,dic) alt.addLast(new_list,video['video_id']) return dic_list
def addLast(lst, element): """ Agrega un elemento en la última posición de la lista. Se adiciona un elemento en la última posición de la lista y se actualiza el apuntador a la útima posición. Se incrementa el tamaño de la lista en 1 Args: lst: La lista en la que se inserta el elemento element: El elemento a insertar Raises: Exception """ try: if (lst['type'] == 'ARRAY_LIST'): alt.addLast(lst, element) else: slt.addLast(lst, element) except Exception as exp: error.reraise(exp, 'List->addLast: ')
def addVideoCategory(catalog, video): alt.addLast(catalog['videos'], video) addCategory(catalog,video) addCountry(catalog,video)
def addIdName_Category(catalog,category): alt.addLast(catalog['idname_category'], category)