mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[imagetwist] add extractor
This commit is contained in:
parent
810aa4e146
commit
56876b76f1
@ -25,6 +25,7 @@ modules = [
|
||||
"hentaifoundry",
|
||||
"hitomi",
|
||||
"imagebam",
|
||||
"imagetwist",
|
||||
"imgbox",
|
||||
"imgchili",
|
||||
"imgth",
|
||||
|
38
gallery_dl/extractor/imagetwist.py
Normal file
38
gallery_dl/extractor/imagetwist.py
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 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://imagetwist.com/"""
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .. import text
|
||||
|
||||
class ImagetwistExtractor(Extractor):
|
||||
|
||||
category = "imagetwist"
|
||||
directory_fmt = ["{category}"]
|
||||
filename_fmt = "{category}_{index}_{filename}"
|
||||
pattern = [r"(?:https?://)?(?:www\.)?imagetwist\.com/([^/]+)"]
|
||||
|
||||
def __init__(self, match):
|
||||
Extractor.__init__(self)
|
||||
self.token = match.group(1)
|
||||
|
||||
def items(self):
|
||||
yield Message.Version, 1
|
||||
page = self.request("http://imagetwist.com/" + self.token).text
|
||||
url , pos = text.extract(page, '<img src="', '"')
|
||||
filename, pos = text.extract(page, ' alt="', '"', pos)
|
||||
index , pos = text.extract(url , '/', '/', 29)
|
||||
data = {
|
||||
"category": self.category,
|
||||
"token": self.token,
|
||||
"index": index,
|
||||
}
|
||||
text.nameext_from_url(filename, data)
|
||||
yield Message.Directory, data
|
||||
yield Message.Url, url, data
|
Loading…
Reference in New Issue
Block a user