[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

@@ -56,6 +56,7 @@ modules = [
"nijie", "nijie",
"pinterest", "pinterest",
"powermanga", "powermanga",
"rapidimg",
"rule34", "rule34",
"safebooru", "safebooru",
"sankaku", "sankaku",

View File

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

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Extract images from http://rapidimg.net/"""
from . import imgyt
class RapidimgImageExtractor(imgyt.ImgytImageExtractor):
"""Extractor for single images from rapidimg.net"""
category = "rapidimg"
pattern = [r"(?:https?://)?(?:www\.)?rapidimg\.net/img-([a-z0-9]+)\.html"]
url = "http://rapidimg.net"
https = False