podcast_newsletter / search_recommend.py
bpHigh's picture
Update search_recommend.py
bd070c6
raw
history blame
977 Bytes
from listennotes import podcast_api
import os
api_key = os.environ['LISTENNOTES']
def search(query):
client = podcast_api.Client(api_key=api_key)
response = client.search(
q=query, sort_by_date=0, only_in='title,description', offset=5, unique_podcasts=0)
results = response.json()
results_final = results['results']
final_string = """ """
number = 1
for item in results_final:
final_string += f"{number}. "
final_string += f"Podcast ID:-{item['id']}\n"
final_string += f"Link:-{item['link']}\n"
final_string += f"Title:-{item['title_original']}\n"
final_string += f"![{item['title_highlighted']}]({item['thumbnail']} '{item['title_original']}')\n\n"
final_string += "\n\n"
number += 1
return final_string
def search_chat_respond(normal_msg,normal_chatbot):
response = search(normal_msg)
normal_chatbot.append((normal_msg,response))
return "", normal_chatbot