1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[reddit] add 'home' extractor (#2614)

This commit is contained in:
Mike Fährmann 2022-05-26 15:01:46 +02:00
parent b51f5fd345
commit d4e9d51760
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 21 additions and 4 deletions

View File

@ -658,7 +658,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>Reddit</td>
<td>https://www.reddit.com/</td>
<td>individual Images, Submissions, Subreddits, User Profiles</td>
<td>Home Feed, individual Images, Submissions, Subreddits, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a></td>
</tr>
<tr>

View File

@ -144,8 +144,8 @@ class RedditExtractor(Extractor):
class RedditSubredditExtractor(RedditExtractor):
"""Extractor for URLs from subreddits on reddit.com"""
subcategory = "subreddit"
pattern = (r"(?:https?://)?(?:\w+\.)?reddit\.com/r/"
r"([^/?#]+(?:/([a-z]+))?)/?(?:\?([^#]*))?(?:$|#)")
pattern = (r"(?:https?://)?(?:\w+\.)?reddit\.com"
r"(/r/[^/?#]+(?:/([a-z]+))?)/?(?:\?([^#]*))?(?:$|#)")
test = (
("https://www.reddit.com/r/lavaporn/", {
"range": "1-20",
@ -168,6 +168,20 @@ class RedditSubredditExtractor(RedditExtractor):
return self.api.submissions_subreddit(self.subreddit, self.params)
class RedditHomeExtractor(RedditSubredditExtractor):
"""Extractor for submissions from your home feed on reddit.com"""
subcategory = "home"
pattern = (r"(?:https?://)?(?:\w+\.)?reddit\.com"
r"((?:/([a-z]+))?)/?(?:\?([^#]*))?(?:$|#)")
test = (
("https://www.reddit.com/", {
"range": "1-20",
"count": ">= 20",
}),
("https://old.reddit.com/top/?sort=top&t=month"),
)
class RedditUserExtractor(RedditExtractor):
"""Extractor for URLs from posts by a reddit user"""
subcategory = "user"
@ -321,7 +335,7 @@ class RedditAPI():
def submissions_subreddit(self, subreddit, params):
"""Collect all (submission, comments)-tuples of a subreddit"""
endpoint = "/r/" + subreddit + "/.json"
endpoint = subreddit + "/.json"
params["limit"] = 100
return self._pagination(endpoint, params)

View File

@ -197,6 +197,9 @@ SUBCATEGORY_MAP = {
"sketch": "Sketch",
"work": "individual Images",
},
"reddit": {
"home": "Home Feed",
},
"sankaku": {
"books": "Book Searches",
},