Merge pull request #165 from andronedev/master

Add Docker support
pull/233/head
Callum Leslie 3 years ago committed by GitHub
commit db1ddce57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1 @@
Dockerfile

1
.gitignore vendored

@ -2,3 +2,4 @@ assets/
.env
reddit-bot-351418-5560ebc49cac.json
__pycache__
out

@ -0,0 +1,15 @@
FROM mcr.microsoft.com/playwright
RUN apt update
RUN apt install python3-pip -y
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
# tricks for pytube : https://github.com/elebumm/RedditVideoMakerBot/issues/142
# (NOTE : This is no longer useful since pytube was removed from the dependencies)
# RUN sed -i 's/re.compile(r"^\\w+\\W")/re.compile(r"^\\$*\\w+\\W")/' /usr/local/lib/python3.8/dist-packages/pytube/cipher.py
CMD ["python3", "main.py"]

@ -0,0 +1 @@
docker build -t rvmt .

@ -0,0 +1 @@
docker run -v $(pwd)/out/:/app/assets -v $(pwd)/.env:/app/.env -it rvmt

@ -1,4 +1,4 @@
from playwright.sync_api import sync_playwright
from playwright.sync_api import sync_playwright, ViewportSize
from pathlib import Path
from rich.progress import track
from utils.console import print_step, print_substep
@ -31,7 +31,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
# Get the thread screenshot
page = context.new_page()
page.goto(reddit_object["thread_url"])
page.set_viewport_size(ViewportSize(width=1920, height=1080))
if page.locator('[data-testid="content-gate"]').is_visible():
# This means the post is NSFW and requires to click the proceed button.
@ -57,4 +57,6 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
page.locator(f"#t1_{comment['comment_id']}").screenshot(
path=f"assets/png/comment_{idx}.png"
)
print_substep("Screenshots downloaded successfully.", style="bold green")
print_substep("Screenshots downloaded Successfully.",
style="bold green")

Loading…
Cancel
Save