1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-24 03:32:33 +01:00
gallery-dl/gallery_dl/extractor/chronos.py
2015-12-04 20:33:04 +01:00

44 lines
1.3 KiB
Python

# -*- 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://chronos.to/"""
from .common import Extractor, Message
from .. import text
class ChronosExtractor(Extractor):
category = "chronos"
directory_fmt = ["{category}"]
filename_fmt = "{filename}"
pattern = [r"(?:https?://)?(?:www\.)?chronos\.to/([a-z0-9]{12})"]
def __init__(self, match):
Extractor.__init__(self)
self.token = match.group(1)
def items(self):
params = {
"op": "view",
"id": self.token,
"pre": 1,
"next": "Continue to image.",
}
page = self.request("http://chronos.to/" + self.token, method="post",
data=params).text
url , pos = text.extract(page, '<img src="', '"')
filename, pos = text.extract(page, ' alt="', '"', pos)
data = {
"category": self.category,
"token": self.token,
}
text.nameext_from_url(filename, data)
yield Message.Version, 1
yield Message.Directory, data
yield Message.Url, url, data