def fetch_results(): """ Method called from the app.py to send the results to the client RETURNS: List of dictionaries. """ results = [] index=0 for query in source_parser(): yt_search_result = yt_handler.search(query)[0] results.append(dict(id=index, url=yt_search_result['url'], name=yt_search_result['name'], thumbnail_url=yt_search_result['thumbnail_url']) ) index+=1 return results
def fetch_results(): """ Method called from the app.py to send the results to the client RETURNS: List of dictionaries. """ results = [] index = 0 for query in source_parser(): yt_search_result = yt_handler.search(query)[0] results.append( dict(id=index, url=yt_search_result['url'], name=yt_search_result['name'], thumbnail_url=yt_search_result['thumbnail_url'])) index += 1 return results
def search(self, query): yt_search_results = yt_handler.search(query, maxResults=4) results = map(lambda index, yt_search_result: dict(id=index, url=yt_search_result['url'], name=yt_search_result['name'], thumbnail_url=yt_search_result['thumbnail_url']) , range(len(yt_search_results)), yt_search_results ) return {'results': results}