FarhadMadadzade commited on
Commit
02cd7fa
1 Parent(s): b44d1eb

added rick roll

Browse files
Files changed (3) hide show
  1. app.py +8 -3
  2. requirements.txt +2 -1
  3. video_downloader.py +15 -0
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
  import time
4
- from video_downloader import download_video1
5
  from moviepy.editor import AudioFileClip, VideoFileClip
6
  from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
7
  import datetime
@@ -15,7 +15,10 @@ pipe = pipeline("automatic-speech-recognition", model="Artanis1551/whisper_swedi
15
  def process_video1(date):
16
  # If the date is not in YYYY-MM-DD format, return an error message
17
  if not date or len(date) != 10 or date[4] != "-" or date[7] != "-":
18
- return "", "Please enter a date in the format YYYY-MM-DD."
 
 
 
19
  try:
20
  video_path = download_video1(date)
21
 
@@ -48,7 +51,9 @@ def process_video1(date):
48
  # Remove the audio file
49
  os.remove(audio_path)
50
  except:
51
- video_path = ""
 
 
52
  transcription = "No decision was made on this date."
53
 
54
  return video_path, transcription
 
1
  from transformers import pipeline
2
  import gradio as gr
3
  import time
4
+ from video_downloader import download_video1, download_youtube_video
5
  from moviepy.editor import AudioFileClip, VideoFileClip
6
  from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
7
  import datetime
 
15
  def process_video1(date):
16
  # If the date is not in YYYY-MM-DD format, return an error message
17
  if not date or len(date) != 10 or date[4] != "-" or date[7] != "-":
18
+ video_path = download_youtube_video(
19
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
20
+ )
21
+ transcription = "Please enter a date in the format YYYY-MM-DD."
22
  try:
23
  video_path = download_video1(date)
24
 
 
51
  # Remove the audio file
52
  os.remove(audio_path)
53
  except:
54
+ video_path = download_youtube_video(
55
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
56
+ )
57
  transcription = "No decision was made on this date."
58
 
59
  return video_path, transcription
requirements.txt CHANGED
@@ -8,4 +8,5 @@ torch
8
  urllib3
9
  moviepy
10
  pydub
11
- beautifulsoup4
 
 
8
  urllib3
9
  moviepy
10
  pydub
11
+ beautifulsoup4
12
+ pytube
video_downloader.py CHANGED
@@ -1,6 +1,7 @@
1
  import urllib.request
2
  import requests
3
  from bs4 import BeautifulSoup
 
4
 
5
 
6
  def get_response(url):
@@ -55,3 +56,17 @@ def download_video1(date):
55
  except Exception as e:
56
  print(f"An error occurred while downloading the video: {e}")
57
  return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import urllib.request
2
  import requests
3
  from bs4 import BeautifulSoup
4
+ from pytube import YouTube
5
 
6
 
7
  def get_response(url):
 
56
  except Exception as e:
57
  print(f"An error occurred while downloading the video: {e}")
58
  return None
59
+
60
+
61
+ def download_youtube_video(url):
62
+ try:
63
+ youtube = YouTube(url)
64
+ video = youtube.streams.get_highest_resolution()
65
+ video_path = video.download()
66
+ print(f"Video downloaded successfully.")
67
+ return video_path
68
+ except Exception as e:
69
+ print(f"An error occurred while downloading the video: {e}")
70
+
71
+
72
+ download_youtube_video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")