Ruslan Magana Vsevolodovna commited on
Commit
37295a9
1 Parent(s): 590d379

Adding limits to the video

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -30,24 +30,27 @@ def download_video(url):
30
 
31
  def validate_youtube(url):
32
  #This creates a youtube objet
33
- yt = YouTube(url)
 
 
 
 
34
  #This will return the length of the video in sec as an int
35
  video_length = yt.length
36
  if video_length > 600:
37
  print("Your video is larger than 10 minutes")
38
- #return False
39
  else:
40
  print("Your video is less than 10 minutes")
41
- #return True
42
-
43
 
44
  def validate_url(url):
45
  import validators
46
  if not validators.url(url):
47
  print("Hi there URL seems invalid ")
48
- return False
49
  else:
50
- return True
51
 
52
 
53
  def cleanup():
@@ -94,6 +97,9 @@ os.environ['home_dir'] = home_dir
94
  os.environ['temp_dir'] = temp_dir
95
 
96
  def video_to_translate(url,initial_language,final_language):
 
 
 
97
 
98
  #Internal definitions
99
  if initial_language == "English":
 
30
 
31
  def validate_youtube(url):
32
  #This creates a youtube objet
33
+ try:
34
+ yt = YouTube(url)
35
+ except Exception:
36
+ print("Hi there URL seems invalid")
37
+ return True
38
  #This will return the length of the video in sec as an int
39
  video_length = yt.length
40
  if video_length > 600:
41
  print("Your video is larger than 10 minutes")
42
+ return True
43
  else:
44
  print("Your video is less than 10 minutes")
45
+ return False
 
46
 
47
  def validate_url(url):
48
  import validators
49
  if not validators.url(url):
50
  print("Hi there URL seems invalid ")
51
+ return True
52
  else:
53
+ return False
54
 
55
 
56
  def cleanup():
 
97
  os.environ['temp_dir'] = temp_dir
98
 
99
  def video_to_translate(url,initial_language,final_language):
100
+ print('Checking the url')
101
+ check =validate_youtube(url)
102
+ if check is True: return "./demo/tryagain2.mp4"
103
 
104
  #Internal definitions
105
  if initial_language == "English":