Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -226,25 +226,25 @@ def generate_valid_filename(query):
|
|
226 |
import whisper
|
227 |
import time
|
228 |
from pytube import YouTube
|
229 |
-
|
230 |
-
|
231 |
|
232 |
def download_video(url):
|
|
|
|
|
|
|
|
|
|
|
233 |
try:
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
return
|
238 |
-
else:
|
239 |
-
raise ValueError("No suitable stream found.")
|
240 |
-
except PytubeError as e:
|
241 |
-
print(f"PytubeError: {e}")
|
242 |
-
raise
|
243 |
except Exception as e:
|
244 |
-
print(f"
|
245 |
raise
|
246 |
|
247 |
|
|
|
248 |
def video_to_text(filename):
|
249 |
clip = VideoFileClip(filename)
|
250 |
audio_filename = filename[:-4] + ".mp3"
|
|
|
226 |
import whisper
|
227 |
import time
|
228 |
from pytube import YouTube
|
229 |
+
import yt_dlp
|
|
|
230 |
|
231 |
def download_video(url):
|
232 |
+
print(f"Attempting to download video from URL: {url}")
|
233 |
+
ydl_opts = {
|
234 |
+
'format': 'bestvideo+bestaudio/best',
|
235 |
+
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
236 |
+
}
|
237 |
try:
|
238 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
239 |
+
info_dict = ydl.extract_info(url, download=True)
|
240 |
+
print(f"Downloaded: {info_dict['title']}")
|
241 |
+
return info_dict['title'] # Or return other relevant info
|
|
|
|
|
|
|
|
|
|
|
242 |
except Exception as e:
|
243 |
+
print(f"Error: {e}")
|
244 |
raise
|
245 |
|
246 |
|
247 |
+
|
248 |
def video_to_text(filename):
|
249 |
clip = VideoFileClip(filename)
|
250 |
audio_filename = filename[:-4] + ".mp3"
|