Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,15 +72,19 @@ def generate_response(user_input):
|
|
72 |
|
73 |
# Search YouTube for videos related to the selected activity
|
74 |
search = Search(activity)
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
84 |
|
85 |
# Crisis resources
|
86 |
crisis_keywords = ["help", "suicide", "depressed", "emergency", "hurt", "lost"]
|
|
|
72 |
|
73 |
# Search YouTube for videos related to the selected activity
|
74 |
search = Search(activity)
|
75 |
+
|
76 |
+
# Check and debug if the search results are coming in
|
77 |
+
try:
|
78 |
+
search_results = search.results[:3] # limit results to 3 videos
|
79 |
+
if not search_results:
|
80 |
+
st.write(f"No results found for '{activity}'. Please try again.")
|
81 |
+
else:
|
82 |
+
st.write(f"Found {len(search_results)} video(s) related to '{activity}'!")
|
83 |
+
for video in search_results:
|
84 |
+
st.write(f"[{video.title}]({video.watch_url})")
|
85 |
+
except Exception as e:
|
86 |
+
st.write(f"An error occurred while searching for videos: {str(e)}")
|
87 |
+
st.write("Sorry, I couldn't fetch videos at the moment.")
|
88 |
|
89 |
# Crisis resources
|
90 |
crisis_keywords = ["help", "suicide", "depressed", "emergency", "hurt", "lost"]
|