Merge branch 'master' of github.com:samirelanduk/reddit-save
This commit is contained in:
commit
9d40a03903
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM jrottenberg/ffmpeg:4.0-alpine
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV DOCKER=1
|
||||||
|
|
||||||
|
RUN apk add build-base && apk add python3-dev
|
||||||
|
|
||||||
|
RUN echo "**** install Python ****" && \
|
||||||
|
apk add --no-cache python3 && \
|
||||||
|
if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
|
||||||
|
\
|
||||||
|
echo "**** install pip ****" && \
|
||||||
|
python3 -m ensurepip && \
|
||||||
|
rm -r /usr/lib/python*/ensurepip && \
|
||||||
|
pip3 install --no-cache --upgrade pip setuptools wheel && \
|
||||||
|
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi
|
||||||
|
|
||||||
|
|
||||||
|
COPY requirements.txt /opt/app/requirements.txt
|
||||||
|
WORKDIR /opt/app
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "save.py"]
|
||||||
|
CMD []
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
version: "3.2"
|
||||||
|
services:
|
||||||
|
reddit-save:
|
||||||
|
build: .
|
||||||
|
image: reddit-save:latest
|
||||||
|
environment:
|
||||||
|
REDDIT_USERNAME:
|
||||||
|
REDDIT_PASSWORD:
|
||||||
|
REDDIT_CLIENT_ID:
|
||||||
|
REDDIT_SECRET:
|
||||||
|
volumes:
|
||||||
|
- "./archive:/opt/app/archive"
|
4
save.py
Executable file → Normal file
4
save.py
Executable file → Normal file
@ -9,10 +9,12 @@ from utilities import *
|
|||||||
# Get arguments
|
# Get arguments
|
||||||
parser = argparse.ArgumentParser(description="Save reddit posts to file.")
|
parser = argparse.ArgumentParser(description="Save reddit posts to file.")
|
||||||
parser.add_argument("mode", type=str, nargs=1, choices=["saved", "upvoted"], help="The file to convert.")
|
parser.add_argument("mode", type=str, nargs=1, choices=["saved", "upvoted"], help="The file to convert.")
|
||||||
|
|
||||||
|
if os.getenv("DOCKER", "0") != "1":
|
||||||
parser.add_argument("location", type=str, nargs=1, help="The path to save to.")
|
parser.add_argument("location", type=str, nargs=1, help="The path to save to.")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
mode = args.mode[0]
|
mode = args.mode[0]
|
||||||
location = args.location[0]
|
location = "./archive/" if os.getenv("DOCKER", "0") == "1" else args.location[0]
|
||||||
|
|
||||||
# Is location specified a directory?
|
# Is location specified a directory?
|
||||||
if not os.path.isdir(location):
|
if not os.path.isdir(location):
|
||||||
|
@ -5,8 +5,15 @@ from redvid import Downloader
|
|||||||
import youtube_dl
|
import youtube_dl
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
try:
|
||||||
from secrets import REDDIT_USERNAME, REDDIT_PASSWORD
|
from secrets import REDDIT_USERNAME, REDDIT_PASSWORD
|
||||||
from secrets import REDDIT_CLIENT_ID, REDDIT_SECRET
|
from secrets import REDDIT_CLIENT_ID, REDDIT_SECRET
|
||||||
|
except ImportError:
|
||||||
|
REDDIT_USERNAME = os.getenv("REDDIT_USERNAME")
|
||||||
|
REDDIT_PASSWORD = os.getenv("REDDIT_PASSWORD")
|
||||||
|
REDDIT_CLIENT_ID = os.getenv("REDDIT_CLIENT_ID")
|
||||||
|
REDDIT_SECRET = os.getenv("REDDIT_SECRET")
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = ["gif", "gifv", "jpg", "jpeg", "png"]
|
IMAGE_EXTENSIONS = ["gif", "gifv", "jpg", "jpeg", "png"]
|
||||||
VIDEO_EXTENSIONS = ["mp4"]
|
VIDEO_EXTENSIONS = ["mp4"]
|
||||||
|
Loading…
Reference in New Issue
Block a user