fix no or invalid link
Browse files
app.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
-
import gradio as gr, glob, os, auditok, random, zipfile, wave
|
| 2 |
from pytube import YouTube
|
| 3 |
from moviepy.editor import VideoFileClip
|
| 4 |
import auditok
|
| 5 |
|
| 6 |
def download_video(url):
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
video = yt.streams.get_highest_resolution()
|
| 9 |
video.download()
|
| 10 |
video_path = f"{video.default_filename}"
|
|
|
|
| 1 |
+
import gradio as gr, glob, os, auditok, random, zipfile, wave, pytube.exceptions
|
| 2 |
from pytube import YouTube
|
| 3 |
from moviepy.editor import VideoFileClip
|
| 4 |
import auditok
|
| 5 |
|
| 6 |
def download_video(url):
|
| 7 |
+
try:
|
| 8 |
+
yt = YouTube(url)
|
| 9 |
+
except pytube.exceptions.RegexMatchError:
|
| 10 |
+
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
| 11 |
video = yt.streams.get_highest_resolution()
|
| 12 |
video.download()
|
| 13 |
video_path = f"{video.default_filename}"
|