Better detection of previous post
This commit is contained in:
parent
7af94add96
commit
65ee59722a
|
@ -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)
|
||||
)
|
||||
|
|
Reference in a new issue