diff --git a/dailyreleases/reddit.py b/dailyreleases/reddit.py index b740e8e..5e4869e 100644 --- a/dailyreleases/reddit.py +++ b/dailyreleases/reddit.py @@ -1,4 +1,5 @@ import logging +import re import praw from praw.models import Submission @@ -23,5 +24,10 @@ def submit_post(title, text, subreddit) -> Submission: def get_previous_daily_post(subreddit) -> Submission: logger.info("Getting previous daily post from r/%s", subreddit) - return next(praw.subreddit(subreddit).search('title:"daily releases"', sort="new", syntax="lucene", - time_filter="week")) + posts = praw.subreddit(subreddit).search('title:"daily releases"', sort="new", syntax="lucene", + time_filter="week") + return next( + p + for p in posts + if re.search("daily release.*[(].* \d\d\d\d[)]", p.title, flags=re.IGNORECASE) + )