1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 19:22:32 +01:00
gallery-dl/gallery_dl/extractor/imgchili.py
2015-02-03 00:23:22 +01:00

25 lines
766 B
Python

from .common import BasicExtractor
from ..util import filename_from_url
import re
class Extractor(BasicExtractor):
def __init__(self, match, config):
BasicExtractor.__init__(self, config)
self.url = match.group(0)
self.page = self.request(self.url).text;
self.category = "imgchili"
title = self.get_title()
pos = self.url.rindex("/")
self.directory = title + " - " + self.url[pos+1:]
def images(self):
pattern = r' src="http://t(\d+\.imgchili.net/[^"]+)"'
for match in re.finditer(pattern, self.page):
url = "http://i" + match.group(1)
yield url, filename_from_url(url)
def get_title(self):
return self.extract(self.page, "<h1>", "</h1>")[0]