mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
merge #6389: [reddit] support user profile share links
This commit is contained in:
commit
2bbae0e98d
@ -340,18 +340,16 @@ class RedditRedirectExtractor(Extractor):
|
|||||||
category = "reddit"
|
category = "reddit"
|
||||||
subcategory = "redirect"
|
subcategory = "redirect"
|
||||||
pattern = (r"(?:https?://)?(?:"
|
pattern = (r"(?:https?://)?(?:"
|
||||||
r"(?:\w+\.)?reddit\.com/(?:(?:r)/([^/?#]+)))"
|
r"(?:\w+\.)?reddit\.com/(?:(r|u|user)/([^/?#]+)))"
|
||||||
r"/s/([a-zA-Z0-9]{10})")
|
r"/s/([a-zA-Z0-9]{10})")
|
||||||
example = "https://www.reddit.com/r/SUBREDDIT/s/abc456GHIJ"
|
example = "https://www.reddit.com/r/SUBREDDIT/s/abc456GHIJ"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
Extractor.__init__(self, match)
|
|
||||||
self.subreddit = match.group(1)
|
|
||||||
self.share_url = match.group(2)
|
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
url = "https://www.reddit.com/r/" + self.subreddit + "/s/" + \
|
sub_type, subreddit, share_url = self.groups
|
||||||
self.share_url
|
if sub_type == "u":
|
||||||
|
sub_type = "user"
|
||||||
|
url = "https://www.reddit.com/{}/{}/s/{}".format(
|
||||||
|
sub_type, subreddit, share_url)
|
||||||
data = {"_extractor": RedditSubmissionExtractor}
|
data = {"_extractor": RedditSubmissionExtractor}
|
||||||
response = self.request(url, method="HEAD", allow_redirects=False,
|
response = self.request(url, method="HEAD", allow_redirects=False,
|
||||||
notfound="submission")
|
notfound="submission")
|
||||||
|
@ -268,4 +268,20 @@ __tests__ = (
|
|||||||
"#pattern" : r"^https://www\.reddit\.com/r/analog/comments/179exao/photographing_the_recent_annular_eclipse_with_a",
|
"#pattern" : r"^https://www\.reddit\.com/r/analog/comments/179exao/photographing_the_recent_annular_eclipse_with_a",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.reddit.com/u/Tailhook91/s/w4yAMbtOYm",
|
||||||
|
"#comment" : "Mobile share URL, user submission",
|
||||||
|
"#category": ("", "reddit", "redirect"),
|
||||||
|
"#class" : reddit.RedditRedirectExtractor,
|
||||||
|
"#pattern" : r"^https://www.reddit.com/user/Tailhook91/comments/znfxbr/prove_it/",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.reddit.com/user/Tailhook91/s/w4yAMbtOYm",
|
||||||
|
"#comment" : "Mobile share URL, user submission",
|
||||||
|
"#category": ("", "reddit", "redirect"),
|
||||||
|
"#class" : reddit.RedditRedirectExtractor,
|
||||||
|
"#pattern" : r"^https://www.reddit.com/user/Tailhook91/comments/znfxbr/prove_it/",
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user