diff options
Diffstat (limited to 'module/plugins/hoster/DlFreeFr.py')
-rw-r--r-- | module/plugins/hoster/DlFreeFr.py | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index 030f7e971..f9d427c1b 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -5,7 +5,6 @@ import re from module.network.Browser import Browser from module.network.CookieJar import CookieJar -from module.plugins.internal.AdYouLike import AdYouLike from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns @@ -36,7 +35,8 @@ class CustomBrowser(Browser): class DlFreeFr(SimpleHoster): __name__ = "DlFreeFr" __type__ = "hoster" - __version__ = "0.29" + __version__ = "0.32" + __status__ = "testing" __pattern__ = r'http://(?:www\.)?dl\.free\.fr/(\w+|getfile\.pl\?file=/\w+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -44,24 +44,24 @@ class DlFreeFr(SimpleHoster): __description__ = """Dl.free.fr hoster plugin""" __license__ = "GPLv3" __authors__ = [("the-razer", "daniel_ AT gmx DOT net"), - ("zoidberg", "zoidberg@mujmail.cz"), - ("Toilal", "toilal.dev@gmail.com")] + ("zoidberg" , "zoidberg@mujmail.cz" ), + ("Toilal" , "toilal.dev@gmail.com" )] - NAME_PATTERN = r'Fichier:</td>\s*<td.*?>(?P<N>[^>]*)</td>' - SIZE_PATTERN = r'Taille:</td>\s*<td.*?>(?P<S>[\d.,]+\w)o' + NAME_PATTERN = r'Fichier:</td>\s*<td.*?>(?P<N>[^>]*)</td>' + SIZE_PATTERN = r'Taille:</td>\s*<td.*?>(?P<S>[\d.,]+\w)o' OFFLINE_PATTERN = r'Erreur 404 - Document non trouv|Fichier inexistant|Le fichier demandé n\'a pas été trouvé' def setup(self): - self.resumeDownload = True + self.resume_download = True self.multiDL = True self.limitDL = 5 - self.chunkLimit = 1 + self.chunk_limit = 1 def init(self): - factory = self.core.requestFactory + factory = self.pyload.requestFactory self.req = CustomBrowser(factory.bucket, factory.getOptions()) @@ -77,13 +77,15 @@ class DlFreeFr(SimpleHoster): if headers.get('code') == 200: content_type = headers.get('content-type') if content_type and content_type.startswith("text/html"): - # Undirect acces to requested file, with a web page providing it (captcha) + #: Undirect acces to requested file, with a web page providing it (captcha) self.html = self.load(valid_url) - self.handleFree(pyfile) + self.handle_free(pyfile) else: - # Direct access to requested file for users using free.fr as Internet Service Provider. + #: Direct access to requested file for users using free.fr as Internet Service Provider. self.link = valid_url + self.download(self.link, disposition=True) + elif headers.get('code') == 404: self.offline() @@ -91,33 +93,27 @@ class DlFreeFr(SimpleHoster): self.fail(_("Invalid return code: ") + str(headers.get('code'))) - def handleFree(self, pyfile): - action, inputs = self.parseHtmlForm('action="getfile.pl"') - - adyoulike = AdYouLike(self) - response, challenge = adyoulike.challenge() - inputs.update(response) - + def handle_free(self, pyfile): + action, inputs = self.parse_html_form('action="getfile.pl"') self.load("http://dl.free.fr/getfile.pl", post=inputs) - headers = self.getLastHeaders() + headers = self.get_last_headers() if headers.get("code") == 302 and "set-cookie" in headers and "location" in headers: - m = re.search("(.*?)=(.*?); path=(.*?); domain=(.*?)", headers.get("set-cookie")) - cj = CookieJar(__name__) + m = re.search("(.*?)=(.*?); path=(.*?); domain=(.*)", headers.get("set-cookie")) + cj = CookieJar(self.__name__) if m: cj.setCookie(m.group(4), m.group(1), m.group(2), m.group(3)) else: self.fail(_("Cookie error")) self.link = headers.get("location") - self.req.setCookieJar(cj) else: self.fail(_("Invalid response")) - def getLastHeaders(self): - #parse header - header = {"code": self.req.code} + def get_last_headers(self): + #: Parse header + header = {'code': self.req.code} for line in self.req.http.header.splitlines(): line = line.strip() if not line or ":" not in line: @@ -128,7 +124,7 @@ class DlFreeFr(SimpleHoster): value = value.strip() if key in header: - if type(header[key]) == list: + if type(header[key]) is list: header[key].append(value) else: header[key] = [header[key], value] |