Better detection of previous post
This commit is contained in:
parent
7af94add96
commit
65ee59722a
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
import praw
|
import praw
|
||||||
from praw.models import Submission
|
from praw.models import Submission
|
||||||
|
@ -23,5 +24,10 @@ def submit_post(title, text, subreddit) -> Submission:
|
||||||
|
|
||||||
def get_previous_daily_post(subreddit) -> Submission:
|
def get_previous_daily_post(subreddit) -> Submission:
|
||||||
logger.info("Getting previous daily post from r/%s", subreddit)
|
logger.info("Getting previous daily post from r/%s", subreddit)
|
||||||
return next(praw.subreddit(subreddit).search('title:"daily releases"', sort="new", syntax="lucene",
|
posts = praw.subreddit(subreddit).search('title:"daily releases"', sort="new", syntax="lucene",
|
||||||
time_filter="week"))
|
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