from .common import AsyncExtractor class Extractor(AsyncExtractor): def __init__(self, match, config): AsyncExtractor.__init__(self, config) self.url = match.group(1) self.cache = None self.category = "imgbox" title = self.get_title() self.directory = title + " - " + self.url[3:] def images(self): text = self.cache or self.request("http://imgbox.com" + self.url).text pos = 0 while True: key, pos = self.extract(text, '.s.imgbox.com/', '.', pos) if key is None: return page = self.request("http://imgbox.com/"+key).text num , p = self.extract(page, '   ', ' of ') url , p = self.extract(page, '03}-{}".format(num, name) def get_title(self): text = self.request("http://imgbox.com/" + self.url).text title, _ = self.extract(text, "

", "

") if title: self.cache = text title = title[:title.rindex(" - ")] else: _, pos = self.extract(text, '
', '') self.url, pos = self.extract(text, '', pos) title, _ = self.extract(text, '', '', pos) return title