add Docker support

pull/165/head
andronedev 3 years ago
parent 4e4934069f
commit 593094d14b

@ -0,0 +1 @@
Dockerfile

4
.gitignore vendored

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

@ -0,0 +1,14 @@
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
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 -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
@ -24,7 +24,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num):
# Get the thread screenshot
page = browser.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.
@ -50,4 +50,5 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num):
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