def find_video_items(item=None, data=None): """ Función genérica para buscar vídeos en una página, devolviendo un itemlist con los items listos para usar. - Si se pasa un Item como argumento, a los items resultantes mantienen los parametros del item pasado - Si no se pasa un Item, se crea uno nuevo, pero no contendra ningun parametro mas que los propios del servidor. @param item: Item al cual se quieren buscar vídeos, este debe contener la url válida @type item: Item @param data: Cadena con el contendio de la página ya descargado (si no se pasa item) @type data: str @return: devuelve el itemlist con los resultados @rtype: list """ logger.info() itemlist = [] # Descarga la página if data is None: data = httptools.downloadpage(item.url).data #Crea un item si no hay item if item is None: item = Item() #Pasa los campos thumbnail y title a contentThumbnail y contentTitle else: if not item.contentThumbnail: item.contentThumbnail = item.thumbnail if not item.contentTitle: item.contentTitle = item.title # Busca los enlaces a los videos for label, url, server, thumbnail in findvideos(data): # DrZ3r0 title = item.title.strip() + " - " + label.strip() if item.thumbnail: thumbnail = item.thumbnail itemlist.append( item.clone(title=title, action="play", url=url, thumbnail=thumbnail, server=server, folder=False)) return itemlist
def find_video_items(item=None, data=None): """ Generic function to search for videos on a page, returning an itemlist with the ready-to-use items. - If an Item is passed as an argument, the resulting items keep the parameters of the last item - If an Item is not passed, a new one is created, but it will not contain any parameters other than those of the server. @param item: Item to which you want to search for videos, this must contain the valid url @type item: Item @param data: String with the page content already downloaded (if item is not passed) @type data: str @return: returns the itemlist with the results @rtype: list """ logger.info() itemlist = [] # Download the page if data is None: data = httptools.downloadpage(item.url).data data = unshortenit.findlinks(data) # Create an item if there is no item if item is None: item = Item() # Pass the thumbnail and title fields to contentThumbnail and contentTitle else: if not item.contentThumbnail: item.contentThumbnail = item.thumbnail if not item.contentTitle: item.contentTitle = item.title # Find the links to the videos for label, url, server, thumbnail in findvideos(data): title = config.get_localized_string(70206) % label itemlist.append( item.clone(title=title, action="play", url=url, thumbnail=thumbnail, server=server, folder=False)) return itemlist