[fappic] rewrite thumbnail URLs (#8013)
This commit is contained in:
@@ -372,19 +372,24 @@ class ImgclickImageExtractor(ImagehostImageExtractor):
|
||||
class FappicImageExtractor(ImagehostImageExtractor):
|
||||
"""Extractor for single images from fappic.com"""
|
||||
category = "fappic"
|
||||
pattern = r"(?:https?://)?((?:www\.)?fappic\.com/(\w+)/[^/?#]+)"
|
||||
example = "https://fappic.com/abc123/NAME.EXT"
|
||||
pattern = (r"(?:https?://)?(?:www\.|img\d+\.)?fappic\.com"
|
||||
r"/(?:i/\d+/())?(\w{10,})(?:/|\.)\w+")
|
||||
example = "https://fappic.com/abcde12345/NAME.EXT"
|
||||
|
||||
def __init__(self, match):
|
||||
Extractor.__init__(self, match)
|
||||
|
||||
thumb, token = self.groups
|
||||
if thumb is not None and token.endswith("_t"):
|
||||
self.token = token = token[:-2]
|
||||
else:
|
||||
self.token = token
|
||||
self.page_url = f"https://fappic.com/{token}/pic.jpg"
|
||||
|
||||
def get_info(self, page):
|
||||
url , pos = text.extract(page, '<a href="#"><img src="', '"')
|
||||
filename, pos = text.extract(page, 'alt="', '"', pos)
|
||||
|
||||
if filename.startswith("Porn Pics "):
|
||||
filename = filename[10:]
|
||||
elif filename.startswith("Porn-Picture-"):
|
||||
filename = filename[13:]
|
||||
|
||||
return url, filename
|
||||
return url, text.re(r"^Porn[ -]Pic(?:s|ture)[ -]").sub("", filename)
|
||||
|
||||
|
||||
class PicstateImageExtractor(ImagehostImageExtractor):
|
||||
|
||||
@@ -27,4 +27,16 @@ __tests__ = (
|
||||
"token" : "98wxqcklyh8k",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.fappic.com/i/00133/qi2nplzmwq7d_t.jpg",
|
||||
"#comment" : "thumbnail URL (#8013)",
|
||||
"#category": ("imagehost", "fappic", "image"),
|
||||
"#class" : imagehosts.FappicImageExtractor,
|
||||
"#results" : "https://fappic.com/img/lahcoyienda2ftjqkmgdzxiaykeddwewwzw27nbuje/1X08WLv-4q6_0090.jpeg",
|
||||
|
||||
"filename" : "1X08WLv-4q6_0090",
|
||||
"extension": "jpeg",
|
||||
"token" : "qi2nplzmwq7d",
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user