Bey007 commited on
Commit
024c0da
·
verified ·
1 Parent(s): ff1c85a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
  from gtts import gTTS
4
- from youtubesearchpython import VideosSearch
5
  import os
6
 
7
  # Initialize conversational models
@@ -56,10 +56,10 @@ if user_input:
56
  activity = st.selectbox("Choose an activity you'd like to try:", hobbies)
57
 
58
  # Search YouTube for videos related to the selected activity
59
- search = VideosSearch(activity, limit=2)
60
- search_results = search.result()['result']
61
  for video in search_results:
62
- st.write(f"[{video['title']}]({video['link']})")
63
 
64
  # Crisis resources
65
  crisis_keywords = ["help", "suicide", "depressed", "emergency", "hurt", "lost"]
 
1
  import streamlit as st
2
  from transformers import pipeline
3
  from gtts import gTTS
4
+ from pytube import Search
5
  import os
6
 
7
  # Initialize conversational models
 
56
  activity = st.selectbox("Choose an activity you'd like to try:", hobbies)
57
 
58
  # Search YouTube for videos related to the selected activity
59
+ search = Search(activity)
60
+ search_results = search.results[:2] # limit results to 2 videos
61
  for video in search_results:
62
+ st.write(f"[{video.title}]({video.watch_url})")
63
 
64
  # Crisis resources
65
  crisis_keywords = ["help", "suicide", "depressed", "emergency", "hurt", "lost"]