[rapidimg] add extractor

This commit is contained in:
Mike Fährmann
2016-10-03 16:13:05 +02:00
parent 883e702fd6
commit a0c044f0c9
3 changed files with 24 additions and 3 deletions

View File

@@ -19,11 +19,13 @@ class ImgytImageExtractor(Extractor):
directory_fmt = ["{category}"]
filename_fmt = "{filename}"
pattern = [r"(?:https?://)?(?:www\.)?img\.yt/img-([a-z0-9]+)\.html"]
test = [("http://img.yt/img-57a2050547b97.html", {
test = [("https://img.yt/img-57a2050547b97.html", {
"url": "6801fac1ff8335bd27a1665ad27ad64cace2cd84",
"keyword": "7548cc9915f90f5d7ffbafa079085457ae34562c",
"content": "54592f2635674c25677c6872db3709d343cdf92f",
})]
url = "https://img.yt"
https = True
def __init__(self, match):
Extractor.__init__(self)
@@ -31,13 +33,13 @@ class ImgytImageExtractor(Extractor):
def items(self):
params = {"imgContinue": "Continue+to+image+...+"}
page = self.request("https://img.yt/img-" + self.token + ".html",
page = self.request(self.url + "/img-" + self.token + ".html",
method="post", data=params).text
url , pos = text.extract(page, "<img class='centred' src='", "'")
filename, pos = text.extract(page, " alt='", "'", pos)
data = {"token": self.token}
text.nameext_from_url(filename + splitext(url)[1], data)
if url.startswith("http:"):
if self.https and url.startswith("http:"):
url = "https:" + url[5:]
yield Message.Version, 1
yield Message.Directory, data