Skip to content

Commit

Permalink
[imgur] add extractor for subreddit links (closes #500)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 2, 2019
1 parent 38c05df commit 6e23c0d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gallery_dl/extractor/imgur.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ def items(self):
return self._items_queue(self.api.account_favorites(self.key))


class ImgurSubredditExtractor(ImgurExtractor):
"""Extractor for a subreddits's imgur links"""
subcategory = "subreddit"
pattern = BASE_PATTERN + r"/r/([^/?&#]+)"
test = ("https://imgur.com/r/pics", {
"range": "1-100",
"count": 100,
"pattern": r"https?://(i.imgur.com|imgur.com/a)/[\w.]+",
})

def items(self):
return self._items_queue(self.api.gallery_subreddit(self.key))


class ImgurAPI():

def __init__(self, extractor):
Expand All @@ -297,6 +311,10 @@ def account_submissions(self, account):
endpoint = "account/{}/submissions".format(account)
return self._pagination(endpoint)

def gallery_subreddit(self, subreddit):
endpoint = "gallery/r/{}".format(subreddit)
return self._pagination(endpoint)

def album(self, album_hash):
return self._call("album/" + album_hash)

Expand Down

0 comments on commit 6e23c0d

Please sign in to comment.