# -*- coding: utf-8 -*- # # Test links: # http://d-h.st/users/shine/?fld_id=37263#files import re import urlparse from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo class DevhostStFolder(SimpleCrypter): __name__ = "DevhostStFolder" __type__ = "crypter" __version__ = "0.06" __status__ = "stable" __pattern__ = r'http://(?:www\.)?d-h\.st/users/(?P\w+)(/\?fld_id=(?P\d+))?' __config__ = [("use_premium" , "bool", "Use premium account if available" , True), ("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] __description__ = """D-h.st folder decrypter plugin""" __license__ = "GPLv3" __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de"), ("Walter Purcaro", "vuolter@gmail.com")] LINK_PATTERN = r'(?:/> |;">)Back to \w+<)' OFFLINE_PATTERN = r'"/cHP">test\.png<' def check_name_size(self, getinfo=True): if not self.info or getinfo: self.log_debug("File info (BEFORE): %s" % self.info) self.info.update(self.get_info(self.pyfile.url, self.html)) self.log_debug("File info (AFTER): %s" % self.info) try: if self.info['pattern']['ID'] == "0": raise p = r'href="(.+?)">Back to \w+<' m = re.search(p, self.html) html = self.load(urlparse.urljoin("http://d-h.st", m.group(1)), cookies=False) p = '\?fld_id=%s.*?">(.+?)<' % self.info['pattern']['ID'] m = re.search(p, html) self.pyfile.name = m.group(1) except Exception, e: self.log_debug(e) self.pyfile.name = self.info['pattern']['USER'] try: folder = self.info['folder'] = self.pyfile.name except Exception: pass self.log_debug("File name: %s" % self.pyfile.name, "File folder: %s" % self.pyfile.name) getInfo = create_getInfo(DevhostStFolder)