aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/imgur.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/imgur.py')
-rw-r--r--gallery_dl/extractor/imgur.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/gallery_dl/extractor/imgur.py b/gallery_dl/extractor/imgur.py
index b1be995..ce3e1ce 100644
--- a/gallery_dl/extractor/imgur.py
+++ b/gallery_dl/extractor/imgur.py
@@ -116,8 +116,8 @@ class ImgurImageExtractor(ImgurExtractor):
image = self.api.image(self.key)
if not image["title"]:
page = self.request(self.root + "/" + self.key, fatal=False).text
- title = text.extract(page, "<title>", "<")[0]
- image["title"] = (title or "").rpartition(" - ")[0].strip()
+ title = text.extract(page, "<title>", "<")[0] or ""
+ image["title"] = text.unescape(title.rpartition(" - ")[0].strip())
url = self._prepare(image)
yield Message.Version, 1
yield Message.Directory, image
@@ -280,6 +280,20 @@ class ImgurFavoriteExtractor(ImgurExtractor):
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):
@@ -297,6 +311,10 @@ class ImgurAPI():
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)