[reddit] support comment share link (#8434)

This commit is contained in:
enduser420
2025-10-18 22:11:23 +05:30
committed by GitHub
parent 555ac2dcfa
commit e2fb2c009c
2 changed files with 11 additions and 2 deletions

View File

@@ -317,8 +317,8 @@ class RedditSubmissionExtractor(RedditExtractor):
"""Extractor for URLs from a submission on reddit.com"""
subcategory = "submission"
pattern = (r"(?:https?://)?(?:"
r"(?:\w+\.)?reddit\.com/(?:(?:r|u|user)/[^/?#]+"
r"/comments|gallery)|redd\.it)/([a-z0-9]+)")
r"(?:\w+\.)?reddit\.com/(?:(?:(?:r|u|user)/[^/?#]+/)?"
r"comments|gallery)|redd\.it)/([a-z0-9]+)")
example = "https://www.reddit.com/r/SUBREDDIT/comments/id/"
def __init__(self, match):

View File

@@ -179,6 +179,15 @@ __tests__ = (
"#count" : 0,
},
{
"#url" : "https://www.reddit.com/comments/1nz2ic5",
"#comment" : "comment share URL",
"#category": ("", "reddit", "submission"),
"#class" : reddit.RedditSubmissionExtractor,
"#pattern" : r"https://i\.redd\.it/\w+\.png",
"#count" : 2,
},
{
"#url" : "https://www.reddit.com/r/RobloxArt/comments/15ko0qu/",
"#comment" : "comment embeds (#5366)",