diff options
Diffstat (limited to 'module/plugins/hoster/FilebeerInfo.py')
-rw-r--r-- | module/plugins/hoster/FilebeerInfo.py | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/module/plugins/hoster/FilebeerInfo.py b/module/plugins/hoster/FilebeerInfo.py index d7d3640a8..a51f70a09 100644 --- a/module/plugins/hoster/FilebeerInfo.py +++ b/module/plugins/hoster/FilebeerInfo.py @@ -24,37 +24,42 @@ from pycurl import FOLLOWLOCATION class FilebeerInfo(SimpleHoster): __name__ = "FilebeerInfo" __type__ = "hoster" - __pattern__ = r"http://(?:www\.)?filebeer\.info/(?!\d*~f)\w+" - __version__ = "0.01" + __pattern__ = r"http://(?:www\.)?filebeer\.info/(?!\d*~f)(?P<ID>\w+).*" + __version__ = "0.02" __description__ = """Filebeer.info plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") + FILE_NAME_PATTERN = r'Filename:\s*</td>\s*<td>\s*(?P<N>.+?) ' + FILE_SIZE_PATTERN = r'Filesize:\s*</td>\s*<td>\s*(?P<S>[0-9.]+) (?P<U>[kKMG])i?B' FILE_INFO_PATTERN = r'<strong>\s*(?P<N>.+?) \((?P<S>[0-9.]+) (?P<U>[kKMG])i?B\)(<br/>\s*)?</strong>' FILE_OFFLINE_PATTERN = r'<title>Upload Files - FileBeer.info</title>' + FILE_URL_REPLACEMENTS = [(__pattern__, 'http://filebeer.info/\g<ID>~i')] + RECAPTCHA_KEY_PATTERN = r'http://www.google.com/recaptcha/api/(?:challenge|noscript)?k=(\w+)' - FREE_URL_PATTERN = r"<a href='(http://filebeer.info/.+?\?d=1)'>" + DOWNLOAD_URL_PATTERN = r"\[url\](.+?)\[/url\]" WAIT_TIME_PATTERN = r"\(\'\.download-timer-seconds\'\)\.html\((\d+)\)" def setup(self): self.resumeDownload = True - self.multiDL = False - - def handleFree(self): - if not 'id="form-join"' in self.html: - found = re.search(self.FREE_URL_PATTERN, self.html) - url = found.group(1) if found else "%s?d=1" % self.pyfile.url.rstrip('/') - - found = re.search(self.WAIT_TIME_PATTERN, self.html) - self.setWait(int(found.group(1)) if found else 60) - self.wait() - - self.html = self.load(url) + self.multiDL = self.premium + def handleFree(self): + url = self.getDownloadUrl() + + for i in range(5): + self.html = self.load(url) + if i == 4 or 'id="form-join"' in self.html: + break + else: + found = re.search(self.WAIT_TIME_PATTERN, self.html) + self.setWait(int(found.group(1)) +1 if found else 61) + self.wait() + action, inputs = self.parseHtmlForm('form-join') if not action: - self.retry(max_tries=5, wait_time=60, reason='Form not found') + self.fail('Form not found') found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) recaptcha_key = found.group(1) if found else '6LeuAc4SAAAAAOSry8eo2xW64K1sjHEKsQ5CaS10' @@ -83,6 +88,13 @@ class FilebeerInfo(SimpleHoster): self.multiDL = True self.req.http.lastURL = action - self.download(download_url) + self.download(download_url) + + def handlePremium(self): + self.download(self.getDownloadUrl()) + + def getDownloadUrl(self): + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + return ("%s?d=1" % found.group(1)) if found else ("http://filebeer.info/%s?d=1" % self.file_info['ID']) getInfo = create_getInfo(FilebeerInfo)
\ No newline at end of file |