From 21d43e906e38a6a8d76eaf6f6de346b6c2431727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Tue, 5 Jul 2022 13:50:53 +0200 Subject: [PATCH] addded new code and reqs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- requirements.txt | 2 ++ save-image.py | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..12094e9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +praw==7.5.0 +requests==2.27.1 diff --git a/save-image.py b/save-image.py index 2d38e9b..8c4e688 100644 --- a/save-image.py +++ b/save-image.py @@ -1,8 +1,12 @@ -import time -import requests -import praw -import os -import json +try: + import time + import requests + import praw + import os + import json +except ImportError: + print("Please install the required python modules with pip install -r requirements.txt or pip3 install -r requirements.txt!") + exit() current_time = time.strftime("%H-%M-%S") current_path = os.path.dirname(os.path.realpath(__file__)) @@ -13,6 +17,10 @@ nswf = False def debugging_message(message : str): print("["+current_time+"][DEBUG] "+message) +if not os.path.isfile(current_path+"/used-posts.json"): + with open(current_path+"/used-posts.json", "w") as used_posts_file: + json.dump({"ids": []}, used_posts_file) + reddit = praw.Reddit(client_id="TB3qNrAO2cnRkpmI-Vd8hg", client_secret="AO61coSKJ8O8KLlHAqP6W-nvufdgUw", user_agent="Meme of the day"