Spaces:
Sleeping
Sleeping
Update search_recommend.py
Browse files- search_recommend.py +25 -0
search_recommend.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from listennotes import podcast_api
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
api_key = os.environ['LISTENNOTES']
|
| 5 |
|
|
@@ -23,7 +24,31 @@ def search(query):
|
|
| 23 |
number += 1
|
| 24 |
return final_string
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def search_chat_respond(normal_msg,normal_chatbot):
|
| 28 |
response = search(normal_msg)
|
| 29 |
normal_chatbot.append((normal_msg,response))
|
|
|
|
| 1 |
from listennotes import podcast_api
|
| 2 |
import os
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
api_key = os.environ['LISTENNOTES']
|
| 6 |
|
|
|
|
| 24 |
number += 1
|
| 25 |
return final_string
|
| 26 |
|
| 27 |
+
def recommend(podcast_id):
|
| 28 |
+
client = podcast_api.Client(api_key=api_key)
|
| 29 |
+
response = client.fetch_recommendations_for_podcast(id=podcast_id)
|
| 30 |
+
results = response.json()
|
| 31 |
+
results_final = results["recommendations"]
|
| 32 |
+
final_string = """ """
|
| 33 |
+
number = 1
|
| 34 |
+
for item in results_final:
|
| 35 |
+
final_string += f"{number}. "
|
| 36 |
+
final_string += f"Title:- {item["title"]}\n"
|
| 37 |
+
final_string += f"Description:- {item["description"]}"
|
| 38 |
+
final_string += f"![{item['title']}]({item['image']} '{item['title']}')\n\n"
|
| 39 |
+
final_string += "\n\n"
|
| 40 |
+
number += 1
|
| 41 |
+
return final_string
|
| 42 |
+
|
| 43 |
|
| 44 |
+
def get_podcast_title(podcast_id):
|
| 45 |
+
client = podcast_api.Client(api_key=api_key)
|
| 46 |
+
response = client.fetch_podcast_by_id(id=podcast_id)
|
| 47 |
+
result = response.json()
|
| 48 |
+
results_final = results["title"]
|
| 49 |
+
return results_final
|
| 50 |
+
|
| 51 |
+
|
| 52 |
def search_chat_respond(normal_msg,normal_chatbot):
|
| 53 |
response = search(normal_msg)
|
| 54 |
normal_chatbot.append((normal_msg,response))
|