Skip to content

Commit

Permalink
swap to gradio and docker added
Browse files Browse the repository at this point in the history
  • Loading branch information
neonwatty committed Jul 17, 2024
1 parent 29d25da commit ada2c13
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 417 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.10-slim

WORKDIR /home

ENV PYTHONPATH=.

COPY requirements.txt /home/requirements.txt
COPY youtube_downloader /home/youtube_downloader
RUN pip3 install -r /home/requirements.txt

EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"

CMD ["gradio", "/home/youtube_downloader/app.py"]
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

A simple python app that lets you painlessly download youtube / shorts video files without needing to visit chintzy sites online. Can be easily run locally. Try it out now in your browser at [![HuggingFace Space](https://img.shields.io/badge/🤗-HuggingFace%20Space-cyan.svg)](https://huggingface.co/spaces/neonwatty/youtube_downloader).

To run the app install the associated `requirements.txt` (in a venv) and run
To run the app install the associated `requirements.txt` and run

```python
python -m streamlit run youtube_downloader/app.py
python youtube_downloader/app.py
```

Or run via Docker

```sh
docker compose up
```
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
youtube_downloader:
build:
context: .
image: youtube_downloader
container_name: youtube_downloader
ports:
- 7860:7860
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pytube
moviepy # make sure ffmpeg is installed on your machine!
streamlit
yt-dlp
gradio==4.38.1
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cwd = os.getcwd()
CONTAINER_NAME = "youtube_downloader"
STREAMLIT_FILE = "youtube_downloader/app.py"
APP_FILE = "youtube_downloader/app.py"
27 changes: 27 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import subprocess
import pytest
import time
from tests import APP_FILE


@pytest.fixture(scope="module")
def start_app():
cmd = f"python {APP_FILE}"
process = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
time.sleep(5)
yield process
process.terminate()
process.wait()


def test_streamlit(subtests, start_app):
with subtests.test(msg="server up"):
assert start_app.poll() is None, "app failed to start"

with subtests.test(msg="streamlit down"):
start_app.terminate()
time.sleep(2)
assert start_app.poll() is not None, "app failed to stop"

27 changes: 0 additions & 27 deletions tests/test_streamlit.py

This file was deleted.

Loading

0 comments on commit ada2c13

Please sign in to comment.