Update app.py
Browse files
app.py
CHANGED
@@ -31,16 +31,26 @@ def download_video(url):
|
|
31 |
return local_file
|
32 |
|
33 |
def validate_youtube(url):
|
34 |
-
#This creates a
|
35 |
try:
|
36 |
yt = YouTube(url)
|
37 |
-
except Exception:
|
38 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
return True
|
40 |
-
|
41 |
-
video_length =
|
42 |
-
|
43 |
-
|
|
|
44 |
return True
|
45 |
else:
|
46 |
print("Your video is less than 10 minutes")
|
|
|
31 |
return local_file
|
32 |
|
33 |
def validate_youtube(url):
|
34 |
+
# This creates a YouTube object
|
35 |
try:
|
36 |
yt = YouTube(url)
|
37 |
+
except Exception as e:
|
38 |
+
print("Invalid URL or network issue:", e)
|
39 |
+
return True
|
40 |
+
|
41 |
+
# Fetch video details safely
|
42 |
+
video_details = yt.vid_info.get('videoDetails', {})
|
43 |
+
length_seconds = video_details.get('lengthSeconds')
|
44 |
+
|
45 |
+
# Ensure lengthSeconds is not None before converting to int
|
46 |
+
if length_seconds is None:
|
47 |
+
print("Error: Could not retrieve video length.")
|
48 |
return True
|
49 |
+
|
50 |
+
video_length = int(length_seconds)
|
51 |
+
|
52 |
+
if video_length > 600:
|
53 |
+
print("Your video is longer than 10 minutes")
|
54 |
return True
|
55 |
else:
|
56 |
print("Your video is less than 10 minutes")
|