Bey007 commited on
Commit
5b7b642
·
verified ·
1 Parent(s): 87eb7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
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
- search_results = search.results[:3] # limit results to 3 videos
76
-
77
- # Debug: Check if search results are found
78
- if search_results:
79
- st.write(f"Found {len(search_results)} video(s) related to '{activity}'!")
80
- for video in search_results:
81
- st.write(f"[{video.title}]({video.watch_url})")
82
- else:
83
- st.write("Sorry, I couldn't find any relevant videos at the moment.")
 
 
 
 
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"]