Update app.py
Browse files
app.py
CHANGED
@@ -226,13 +226,23 @@ def generate_valid_filename(query):
|
|
226 |
import whisper
|
227 |
import time
|
228 |
from pytube import YouTube
|
|
|
229 |
|
230 |
|
231 |
def download_video(url):
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
|
238 |
def video_to_text(filename):
|
|
|
226 |
import whisper
|
227 |
import time
|
228 |
from pytube import YouTube
|
229 |
+
from pytube.exceptions import PytubeError
|
230 |
|
231 |
|
232 |
def download_video(url):
|
233 |
+
try:
|
234 |
+
video = YouTube(url)
|
235 |
+
stream = video.streams.filter(file_extension='mp4').first()
|
236 |
+
if stream:
|
237 |
+
return stream.download()
|
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"Unexpected error: {e}")
|
245 |
+
raise
|
246 |
|
247 |
|
248 |
def video_to_text(filename):
|