1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-26 04:32:51 +01:00

[imgtrex] add extractor

This commit is contained in:
Mike Fährmann 2016-09-09 07:37:13 +02:00
parent dbdd43cff5
commit 155af213a9
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 41 additions and 2 deletions

View File

@ -54,8 +54,8 @@ Supported Sites
* Futaba Channel-like: * Futaba Channel-like:
4chan.org, 8ch.net 4chan.org, 8ch.net
* Image Hosts: * Image Hosts:
chronos.to, imagebam.com, imagetwist.com, img.yt, imgbox.com, imgchili.net, chronos.to, coreimg.net, imagebam.com, imagetwist.com, img.yt, imgbox.com,
turboimagehost.com imgcandy.net, imgchili.net, imgtrex.com. turboimagehost.com
Configuration Configuration

View File

@ -36,6 +36,7 @@ modules = [
"imgcandy", "imgcandy",
"imgchili", "imgchili",
"imgth", "imgth",
"imgtrex",
"imgur", "imgur",
"imgyt", "imgyt",
"khinsider", "khinsider",

View File

@ -0,0 +1,38 @@
# -*- 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://imgtrex.com/"""
from .common import Extractor, Message
from .. import text
class ImgtrexImageExtractor(Extractor):
"""Extractor for single images from imgtrex.com"""
category = "imgtrex"
directory_fmt = ["{category}"]
filename_fmt = "{filename}"
pattern = [r"(?:https?://)?(?:www\.)?imgtrex\.com/([^/]+)"]
test = [("http://imgtrex.com/im0ypxq0rke4/test-テスト-&<a>.png", {
"url": "c000618bddda42bd599a590b7972c7396d19d8fe",
"keyword": "4d766eae04aa5457bca4992290aa28b76239d287",
"content": "0c8768055e4e20e7c7259608b67799171b691140",
})]
def __init__(self, match):
Extractor.__init__(self)
self.token = match.group(1)
def items(self):
data = {"category": self.category, "token": self.token}
page = self.request("http://imgtrex.com/" + self.token).text
filename, pos = text.extract(page, '<title>ImgTrex: ', '</title>')
url , pos = text.extract(page, '<br>\n<img src="', '"', pos)
text.nameext_from_url(filename, data)
yield Message.Version, 1
yield Message.Directory, data
yield Message.Url, url, data