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:
parent
b51f5fd345
commit
d4e9d51760
@ -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>
|
||||
|
@ -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)
|
||||
|
||||
|
@ -197,6 +197,9 @@ SUBCATEGORY_MAP = {
|
||||
"sketch": "Sketch",
|
||||
"work": "individual Images",
|
||||
},
|
||||
"reddit": {
|
||||
"home": "Home Feed",
|
||||
},
|
||||
"sankaku": {
|
||||
"books": "Book Searches",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user