danilotpnta commited on
Commit
f3d3b52
·
1 Parent(s): 7b6fc55

update with docker

Browse files
Files changed (5) hide show
  1. Dockerfile +34 -0
  2. app.py +1 -1
  3. download_video.py +6 -13
  4. environment.yml +0 -12
  5. requirements.txt +0 -9
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install necessary dependencies including ffmpeg
11
+ RUN apt-get update && apt-get install -y \
12
+ wget \
13
+ curl \
14
+ unzip \
15
+ git \
16
+ chromium \
17
+ chromium-driver \
18
+ ffmpeg \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install pip and the required Python packages
22
+ RUN pip install --upgrade pip \
23
+ && pip install selenium requests gradio \
24
+ && pip install git+https://github.com/openai/whisper.git
25
+
26
+ # Set environment variables for Selenium
27
+ ENV CHROME_BIN=/usr/bin/chromium
28
+ ENV CHROMEDRIVER_BIN=/usr/bin/chromedriver
29
+
30
+ # Expose the port the app will run on
31
+ EXPOSE 7860
32
+
33
+ # Command to run the Gradio app
34
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -71,4 +71,4 @@ with gr.Blocks() as interface:
71
 
72
  # Launch the app
73
  if __name__ == "__main__":
74
- interface.launch(share=True)
 
71
 
72
  # Launch the app
73
  if __name__ == "__main__":
74
+ interface.launch(server_name="0.0.0.0", server_port=7860)
download_video.py CHANGED
@@ -1,4 +1,5 @@
1
  from selenium import webdriver
 
2
  from selenium.webdriver.common.by import By
3
  from selenium.webdriver.common.keys import Keys
4
  from selenium.webdriver.support.ui import WebDriverWait
@@ -15,25 +16,17 @@ def download_mp3_selenium(youtube_url):
15
  options.add_argument('--disable-gpu') # Disable GPU to ensure it runs in cloud environments
16
  options.add_argument('--verbose')
17
  options.add_argument('--log-path=/tmp/chromedriver.log')
18
- options.add_argument(
19
- "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.49 Safari/537.36"
20
-
21
- )
22
 
23
  log_contents = "" # Initialize log_contents
24
- driver = webdriver.Chrome(options=options)
25
 
26
- try:
27
- driver.get("https://www.google.com")
28
- print("Page title was '{}'".format(driver.title))
29
- except Exception as e:
30
- print(e)
31
 
32
- print(driver.capabilities['browserVersion'])
33
- print(driver.capabilities['chrome']['chromedriverVersion'])
34
 
35
  # Set up WebDriverWait (with a timeout of 10 seconds)
36
- wait = WebDriverWait(driver, 20)
37
 
38
  # Open the YouTube video page
39
  driver.get(youtube_url)
 
1
  from selenium import webdriver
2
+ from selenium.webdriver.chrome.service import Service
3
  from selenium.webdriver.common.by import By
4
  from selenium.webdriver.common.keys import Keys
5
  from selenium.webdriver.support.ui import WebDriverWait
 
16
  options.add_argument('--disable-gpu') # Disable GPU to ensure it runs in cloud environments
17
  options.add_argument('--verbose')
18
  options.add_argument('--log-path=/tmp/chromedriver.log')
 
 
 
 
19
 
20
  log_contents = "" # Initialize log_contents
 
21
 
22
+ # Use the Service class to specify the path to the ChromeDriver binary
23
+ service = Service(executable_path="/usr/bin/chromedriver")
 
 
 
24
 
25
+ # Pass the service and options to the WebDriver
26
+ driver = webdriver.Chrome(service=service, options=options)
27
 
28
  # Set up WebDriverWait (with a timeout of 10 seconds)
29
+ wait = WebDriverWait(driver, 10)
30
 
31
  # Open the YouTube video page
32
  driver.get(youtube_url)
environment.yml DELETED
@@ -1,12 +0,0 @@
1
- name: yt-whisper-2
2
- channels:
3
- - defaults
4
- - conda-forge
5
- dependencies:
6
- - python=3.9
7
- - pip
8
- - pip:
9
- - selenium
10
- - requests
11
- - gradio
12
- - openai-whisper @ git+https://github.com/openai/whisper.git
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,12 +1,3 @@
1
- # numpy<2 # Pinning NumPy to a version below 2.0
2
- # gradio==3.39.0 # Downgrade Gradio to work with Pydantic v1
3
- # pytube==15.0.0
4
- # git+https://github.com/openai/whisper.git # Install Whisper from GitHub
5
- # torch==2.0.1
6
- # pydantic==1.10 # Use Pydantic v1 to avoid the incompatibility
7
- # git+https://github.com/microsoft/playwright-python.git
8
- # BeautifulSoup4
9
- # requests
10
  selenium
11
  webdriver-manager
12
  requests
 
 
 
 
 
 
 
 
 
 
1
  selenium
2
  webdriver-manager
3
  requests