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"