From 8452ded609d0844ef1af752fb0dd00fb45c7f500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Tue, 5 Jul 2022 14:28:32 +0200 Subject: [PATCH] added some stuff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- .gitignore | 3 +++ save-image.py | 9 +++++---- used-posts.json | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d28ee74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +used-posts.json +*.png +*.json diff --git a/save-image.py b/save-image.py index f80bfc0..9bcfd90 100644 --- a/save-image.py +++ b/save-image.py @@ -10,7 +10,7 @@ except ImportError: current_time = time.strftime("%H-%M-%S") current_path = os.path.dirname(os.path.realpath(__file__)) -subreddit_name = "r/memes" +subreddit_name = "memes" nswf = False @@ -29,12 +29,13 @@ reddit = praw.Reddit(client_id="TB3qNrAO2cnRkpmI-Vd8hg", with open(current_path+"/used-posts.json", "r") as used_posts_file: used_posts = json.load(used_posts_file) -debugging_message("Getting a post from "+subreddit_name) +debugging_message("Getting a post from r/"+subreddit_name) subreddit = reddit.subreddit(subreddit_name) -hot_post = subreddit.hot() -for post in hot_post: +posts = subreddit.top(time_filter="day", limit=5) +for post in posts: try: if post.id not in used_posts['ids']: + print(post.url) if post.url.endswith(".png") or post.url.endswith(".jpg"): debugging_message("Found a new post: "+post.title+" ("+post.id+")") print(post.url) diff --git a/used-posts.json b/used-posts.json index 58caea8..9b52e59 100644 --- a/used-posts.json +++ b/used-posts.json @@ -1 +1 @@ -{"ids": []} \ No newline at end of file +{"ids": ["vrcvgn"]} \ No newline at end of file