use f-strings when building 'pattern'
This commit is contained in:
@@ -67,7 +67,7 @@ class ImgurImageExtractor(ImgurExtractor):
|
||||
subcategory = "image"
|
||||
filename_fmt = "{category}_{id}{title:?_//}.{extension}"
|
||||
archive_fmt = "{id}"
|
||||
pattern = (BASE_PATTERN + r"/(?!gallery|search)"
|
||||
pattern = (rf"{BASE_PATTERN}/(?!gallery|search)"
|
||||
r"(?:r/\w+/)?(?:[^/?#]+-)?(\w{7}|\w{5})[sbtmlh]?")
|
||||
example = "https://imgur.com/abcdefg"
|
||||
|
||||
@@ -93,7 +93,7 @@ class ImgurAlbumExtractor(ImgurExtractor):
|
||||
directory_fmt = ("{category}", "{album[id]}{album[title]:? - //}")
|
||||
filename_fmt = "{category}_{album[id]}_{num:>03}_{id}.{extension}"
|
||||
archive_fmt = "{album[id]}_{id}"
|
||||
pattern = BASE_PATTERN + r"/a/(?:[^/?#]+-)?(\w{7}|\w{5})"
|
||||
pattern = rf"{BASE_PATTERN}/a/(?:[^/?#]+-)?(\w{{7}}|\w{{5}})"
|
||||
example = "https://imgur.com/a/abcde"
|
||||
|
||||
def items(self):
|
||||
@@ -126,7 +126,8 @@ class ImgurAlbumExtractor(ImgurExtractor):
|
||||
class ImgurGalleryExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur galleries"""
|
||||
subcategory = "gallery"
|
||||
pattern = BASE_PATTERN + r"/(?:gallery|t/\w+)/(?:[^/?#]+-)?(\w{7}|\w{5})"
|
||||
pattern = (rf"{BASE_PATTERN}/"
|
||||
rf"(?:gallery|t/\w+)/(?:[^/?#]+-)?(\w{{7}}|\w{{5}})")
|
||||
example = "https://imgur.com/gallery/abcde"
|
||||
|
||||
def items(self):
|
||||
@@ -142,7 +143,7 @@ class ImgurGalleryExtractor(ImgurExtractor):
|
||||
class ImgurUserExtractor(ImgurExtractor):
|
||||
"""Extractor for all images posted by a user"""
|
||||
subcategory = "user"
|
||||
pattern = (BASE_PATTERN + r"/user/(?!me(?:/|$|\?|#))"
|
||||
pattern = (rf"{BASE_PATTERN}/user/(?!me(?:/|$|\?|#))"
|
||||
r"([^/?#]+)(?:/posts|/submitted)?/?$")
|
||||
example = "https://imgur.com/user/USER"
|
||||
|
||||
@@ -153,7 +154,7 @@ class ImgurUserExtractor(ImgurExtractor):
|
||||
class ImgurFavoriteExtractor(ImgurExtractor):
|
||||
"""Extractor for a user's favorites"""
|
||||
subcategory = "favorite"
|
||||
pattern = BASE_PATTERN + r"/user/([^/?#]+)/favorites/?$"
|
||||
pattern = rf"{BASE_PATTERN}/user/([^/?#]+)/favorites/?$"
|
||||
example = "https://imgur.com/user/USER/favorites"
|
||||
|
||||
def items(self):
|
||||
@@ -163,7 +164,7 @@ class ImgurFavoriteExtractor(ImgurExtractor):
|
||||
class ImgurFavoriteFolderExtractor(ImgurExtractor):
|
||||
"""Extractor for a user's favorites folder"""
|
||||
subcategory = "favorite-folder"
|
||||
pattern = BASE_PATTERN + r"/user/([^/?#]+)/favorites/folder/(\d+)"
|
||||
pattern = rf"{BASE_PATTERN}/user/([^/?#]+)/favorites/folder/(\d+)"
|
||||
example = "https://imgur.com/user/USER/favorites/folder/12345/TITLE"
|
||||
|
||||
def __init__(self, match):
|
||||
@@ -178,7 +179,7 @@ class ImgurFavoriteFolderExtractor(ImgurExtractor):
|
||||
class ImgurMeExtractor(ImgurExtractor):
|
||||
"""Extractor for your personal uploads"""
|
||||
subcategory = "me"
|
||||
pattern = BASE_PATTERN + r"/user/me(?:/posts)?(/hidden)?"
|
||||
pattern = rf"{BASE_PATTERN}/user/me(?:/posts)?(/hidden)?"
|
||||
example = "https://imgur.com/user/me"
|
||||
|
||||
def items(self):
|
||||
@@ -195,7 +196,7 @@ class ImgurMeExtractor(ImgurExtractor):
|
||||
class ImgurSubredditExtractor(ImgurExtractor):
|
||||
"""Extractor for a subreddits's imgur links"""
|
||||
subcategory = "subreddit"
|
||||
pattern = BASE_PATTERN + r"/r/([^/?#]+)/?$"
|
||||
pattern = rf"{BASE_PATTERN}/r/([^/?#]+)/?$"
|
||||
example = "https://imgur.com/r/SUBREDDIT"
|
||||
|
||||
def items(self):
|
||||
@@ -205,7 +206,7 @@ class ImgurSubredditExtractor(ImgurExtractor):
|
||||
class ImgurTagExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur tag searches"""
|
||||
subcategory = "tag"
|
||||
pattern = BASE_PATTERN + r"/t/([^/?#]+)$"
|
||||
pattern = rf"{BASE_PATTERN}/t/([^/?#]+)$"
|
||||
example = "https://imgur.com/t/TAG"
|
||||
|
||||
def items(self):
|
||||
@@ -215,7 +216,7 @@ class ImgurTagExtractor(ImgurExtractor):
|
||||
class ImgurSearchExtractor(ImgurExtractor):
|
||||
"""Extractor for imgur search results"""
|
||||
subcategory = "search"
|
||||
pattern = BASE_PATTERN + r"/search(?:/[^?#]+)?/?\?q=([^&#]+)"
|
||||
pattern = rf"{BASE_PATTERN}/search(?:/[^?#]+)?/?\?q=([^&#]+)"
|
||||
example = "https://imgur.com/search?q=UERY"
|
||||
|
||||
def items(self):
|
||||
|
||||
Reference in New Issue
Block a user