remove test results in extractor modules
and add generic example URLs
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
from .common import Extractor, Message
|
||||
from .. import text, exception
|
||||
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?(?:www\.|[im]\.)?imgur\.(?:com|io)"
|
||||
|
||||
|
||||
@@ -65,82 +64,7 @@ class ImgurImageExtractor(ImgurExtractor):
|
||||
archive_fmt = "{id}"
|
||||
pattern = (BASE_PATTERN + r"/(?!gallery|search)"
|
||||
r"(?:r/\w+/)?(\w{7}|\w{5})[sbtmlh]?")
|
||||
test = (
|
||||
("https://imgur.com/21yMxCS", {
|
||||
"url": "6f2dcfb86815bdd72808c313e5f715610bc7b9b2",
|
||||
"content": "0c8768055e4e20e7c7259608b67799171b691140",
|
||||
"keyword": {
|
||||
"account_id" : 0,
|
||||
"comment_count" : int,
|
||||
"cover_id" : "21yMxCS",
|
||||
"date" : "dt:2016-11-10 14:24:35",
|
||||
"description" : "",
|
||||
"downvote_count": int,
|
||||
"duration" : 0,
|
||||
"ext" : "png",
|
||||
"favorite" : False,
|
||||
"favorite_count": 0,
|
||||
"has_sound" : False,
|
||||
"height" : 32,
|
||||
"id" : "21yMxCS",
|
||||
"image_count" : 1,
|
||||
"in_most_viral" : False,
|
||||
"is_ad" : False,
|
||||
"is_album" : False,
|
||||
"is_animated" : False,
|
||||
"is_looping" : False,
|
||||
"is_mature" : False,
|
||||
"is_pending" : False,
|
||||
"mime_type" : "image/png",
|
||||
"name" : "test-テスト",
|
||||
"point_count" : int,
|
||||
"privacy" : "",
|
||||
"score" : int,
|
||||
"size" : 182,
|
||||
"title" : "Test",
|
||||
"upvote_count" : int,
|
||||
"url" : "https://i.imgur.com/21yMxCS.png",
|
||||
"view_count" : int,
|
||||
"width" : 64,
|
||||
},
|
||||
}),
|
||||
# gifv/mp4 video
|
||||
("http://imgur.com/0gybAXR", {
|
||||
"url": "a2220eb265a55b0c95e0d3d721ec7665460e3fd7",
|
||||
"content": "a3c080e43f58f55243ab830569ba02309d59abfc",
|
||||
}),
|
||||
# missing title in API response (#467)
|
||||
("https://imgur.com/XFfsmuC", {
|
||||
"keyword": {"title": "Tears are a natural response to irritants"},
|
||||
}),
|
||||
# animated png
|
||||
("https://imgur.com/1Nily2P", {
|
||||
"pattern": "https://i.imgur.com/1Nily2P.png",
|
||||
}),
|
||||
# not found
|
||||
("https://imgur.com/zzzzzzz", {
|
||||
"exception": exception.HttpError,
|
||||
}),
|
||||
("https://m.imgur.com/r/Celebs/iHJ7tsM"),
|
||||
# www
|
||||
("https://www.imgur.com/21yMxCS"),
|
||||
# mobile
|
||||
("https://m.imgur.com/21yMxCS"),
|
||||
# 5 character key
|
||||
("https://imgur.com/zxaY6"),
|
||||
# .io
|
||||
("https://imgur.io/zxaY6"),
|
||||
# direct link
|
||||
("https://i.imgur.com/21yMxCS.png"),
|
||||
# direct link .io
|
||||
("https://i.imgur.io/21yMxCS.png"),
|
||||
# direct link thumbnail
|
||||
("https://i.imgur.com/21yMxCSh.png"),
|
||||
# direct link (short)
|
||||
("https://i.imgur.com/zxaY6.gif"),
|
||||
# direct link (short; thumb)
|
||||
("https://i.imgur.com/zxaY6s.gif"),
|
||||
)
|
||||
example = "https://imgur.com/abcdefg"
|
||||
|
||||
def items(self):
|
||||
image = self.api.image(self.key)
|
||||
@@ -165,77 +89,7 @@ class ImgurAlbumExtractor(ImgurExtractor):
|
||||
filename_fmt = "{category}_{album[id]}_{num:>03}_{id}.{extension}"
|
||||
archive_fmt = "{album[id]}_{id}"
|
||||
pattern = BASE_PATTERN + r"/a/(\w{7}|\w{5})"
|
||||
test = (
|
||||
("https://imgur.com/a/TcBmP", {
|
||||
"url": "ce3552f550a5b5316bd9c7ae02e21e39f30c0563",
|
||||
"keyword": {
|
||||
"album": {
|
||||
"account_id" : 0,
|
||||
"comment_count" : int,
|
||||
"cover_id" : "693j2Kr",
|
||||
"date" : "dt:2015-10-09 10:37:50",
|
||||
"description" : "",
|
||||
"downvote_count": 0,
|
||||
"favorite" : False,
|
||||
"favorite_count": 0,
|
||||
"id" : "TcBmP",
|
||||
"image_count" : 19,
|
||||
"in_most_viral" : False,
|
||||
"is_ad" : False,
|
||||
"is_album" : True,
|
||||
"is_mature" : False,
|
||||
"is_pending" : False,
|
||||
"privacy" : "private",
|
||||
"score" : int,
|
||||
"title" : "138",
|
||||
"upvote_count" : int,
|
||||
"url" : "https://imgur.com/a/TcBmP",
|
||||
"view_count" : int,
|
||||
"virality" : int,
|
||||
},
|
||||
"account_id" : 0,
|
||||
"count" : 19,
|
||||
"date" : "type:datetime",
|
||||
"description": "",
|
||||
"ext" : "jpg",
|
||||
"has_sound" : False,
|
||||
"height" : int,
|
||||
"id" : str,
|
||||
"is_animated": False,
|
||||
"is_looping" : False,
|
||||
"mime_type" : "image/jpeg",
|
||||
"name" : str,
|
||||
"num" : int,
|
||||
"size" : int,
|
||||
"title" : str,
|
||||
"type" : "image",
|
||||
"updated_at" : None,
|
||||
"url" : str,
|
||||
"width" : int,
|
||||
},
|
||||
}),
|
||||
# large album
|
||||
("https://imgur.com/a/eD9CT", {
|
||||
"url": "de748c181a04d18bef1de9d4f4866ef0a06d632b",
|
||||
}),
|
||||
# 7 character album hash
|
||||
("https://imgur.com/a/RhJXhVT/all", {
|
||||
"url": "695ef0c950023362a0163ee5041796300db76674",
|
||||
}),
|
||||
("https://imgur.com/a/TcBmQ", {
|
||||
"exception": exception.HttpError,
|
||||
}),
|
||||
# empty, no 'media' (#2557)
|
||||
("https://imgur.com/a/pjOnJA0", {
|
||||
"count": 0,
|
||||
}),
|
||||
# www
|
||||
("https://www.imgur.com/a/TcBmP"),
|
||||
# .io
|
||||
("https://imgur.io/a/TcBmP"),
|
||||
# mobile
|
||||
("https://m.imgur.com/a/TcBmP"),
|
||||
)
|
||||
example = "https://imgur.com/a/abcde"
|
||||
|
||||
def items(self):
|
||||
album = self.api.album(self.key)
|
||||
@@ -268,19 +122,7 @@ class ImgurGalleryExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur galleries"""
|
||||
subcategory = "gallery"
|
||||
pattern = BASE_PATTERN + r"/(?:gallery|t/\w+)/(\w{7}|\w{5})"
|
||||
test = (
|
||||
# non-album gallery (#380)
|
||||
("https://imgur.com/gallery/zf2fIms", {
|
||||
"pattern": "https://imgur.com/zf2fIms",
|
||||
}),
|
||||
("https://imgur.com/gallery/eD9CT", {
|
||||
"pattern": "https://imgur.com/a/eD9CT",
|
||||
}),
|
||||
("https://imgur.com/t/unmuted/26sEhNr"),
|
||||
("https://imgur.com/t/cat/qSB8NbN"),
|
||||
# .io
|
||||
("https://imgur.io/t/cat/qSB8NbN"),
|
||||
)
|
||||
example = "https://imgur.com/gallery/abcde"
|
||||
|
||||
def items(self):
|
||||
if self.api.gallery(self.key)["is_album"]:
|
||||
@@ -296,15 +138,7 @@ class ImgurUserExtractor(ImgurExtractor):
|
||||
"""Extractor for all images posted by a user"""
|
||||
subcategory = "user"
|
||||
pattern = BASE_PATTERN + r"/user/([^/?#]+)(?:/posts|/submitted)?/?$"
|
||||
test = (
|
||||
("https://imgur.com/user/Miguenzo", {
|
||||
"range": "1-100",
|
||||
"count": 100,
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
}),
|
||||
("https://imgur.com/user/Miguenzo/posts"),
|
||||
("https://imgur.com/user/Miguenzo/submitted"),
|
||||
)
|
||||
example = "https://imgur.com/user/USER"
|
||||
|
||||
def items(self):
|
||||
return self._items_queue(self.api.account_submissions(self.key))
|
||||
@@ -314,11 +148,7 @@ class ImgurFavoriteExtractor(ImgurExtractor):
|
||||
"""Extractor for a user's favorites"""
|
||||
subcategory = "favorite"
|
||||
pattern = BASE_PATTERN + r"/user/([^/?#]+)/favorites/?$"
|
||||
test = ("https://imgur.com/user/Miguenzo/favorites", {
|
||||
"range": "1-100",
|
||||
"count": 100,
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
})
|
||||
example = "https://imgur.com/user/USER/favorites"
|
||||
|
||||
def items(self):
|
||||
return self._items_queue(self.api.account_favorites(self.key))
|
||||
@@ -328,16 +158,7 @@ class ImgurFavoriteFolderExtractor(ImgurExtractor):
|
||||
"""Extractor for a user's favorites folder"""
|
||||
subcategory = "favorite-folder"
|
||||
pattern = BASE_PATTERN + r"/user/([^/?#]+)/favorites/folder/(\d+)"
|
||||
test = (
|
||||
("https://imgur.com/user/mikf1/favorites/folder/11896757/public", {
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
"count": 3,
|
||||
}),
|
||||
("https://imgur.com/user/mikf1/favorites/folder/11896741/private", {
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
"count": 5,
|
||||
}),
|
||||
)
|
||||
example = "https://imgur.com/user/USER/favorites/folder/12345/TITLE"
|
||||
|
||||
def __init__(self, match):
|
||||
ImgurExtractor.__init__(self, match)
|
||||
@@ -352,11 +173,7 @@ 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://imgur\.com(/a)?/\w+$",
|
||||
})
|
||||
example = "https://imgur.com/r/SUBREDDIT"
|
||||
|
||||
def items(self):
|
||||
return self._items_queue(self.api.gallery_subreddit(self.key))
|
||||
@@ -366,11 +183,7 @@ class ImgurTagExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur tag searches"""
|
||||
subcategory = "tag"
|
||||
pattern = BASE_PATTERN + r"/t/([^/?#]+)$"
|
||||
test = ("https://imgur.com/t/animals", {
|
||||
"range": "1-100",
|
||||
"count": 100,
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
})
|
||||
example = "https://imgur.com/t/TAG"
|
||||
|
||||
def items(self):
|
||||
return self._items_queue(self.api.gallery_tag(self.key))
|
||||
@@ -380,11 +193,7 @@ class ImgurSearchExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur search results"""
|
||||
subcategory = "search"
|
||||
pattern = BASE_PATTERN + r"/search(?:/[^?#]+)?/?\?q=([^&#]+)"
|
||||
test = ("https://imgur.com/search?q=cute+cat", {
|
||||
"range": "1-100",
|
||||
"count": 100,
|
||||
"pattern": r"https://imgur\.com(/a)?/\w+$",
|
||||
})
|
||||
example = "https://imgur.com/search?q=UERY"
|
||||
|
||||
def items(self):
|
||||
key = text.unquote(self.key.replace("+", " "))
|
||||
|
||||
Reference in New Issue
Block a user