Somehow commatization gone

This commit is contained in:
Hans5958 2022-04-07 23:31:13 +07:00
parent 796bd09a15
commit 713ebec844

View file

@ -18,7 +18,7 @@
- [place.reddit.com](https://place.reddit.com)
"""
FS_REGEX = {
"commatization": r',*(?: +(and|&))? +',
"commatization": r'( *(,+ +|,+ |,+)| +)(and|&)( *(,+ +|,+ |,+)| +)',
"pattern1": r'\/*[rR]\/([A-Za-z0-9][A-Za-z0-9_]{1,20})(?:\/$)?',
"pattern2": r'^\/*[rR](?!\/)([A-Za-z0-9][A-Za-z0-9_]{1,20})(?:\/$)?',
"pattern3": r'(?:(?:https?:\/\/)?(?:(?:www|old|new|np)\.)?)?reddit\.com\/r\/([A-Za-z0-9][A-Za-z0-9_]{1,20})(?:\/[^" ]*)*',
@ -47,6 +47,7 @@ def format_subreddit(entry: dict):
return entry
subredditLink = entry["subreddit"]
subredditLink = re.sub(FS_REGEX["commatization"], ', ', subredditLink)
subredditLink = re.sub(FS_REGEX["pattern3"], SUBREDDIT_TEMPLATE, subredditLink)
subredditLink = re.sub(FS_REGEX["pattern1"], SUBREDDIT_TEMPLATE, subredditLink)
subredditLink = re.sub(FS_REGEX["pattern2"], SUBREDDIT_TEMPLATE, subredditLink)