diff options
Diffstat (limited to 'pyload/plugins/hoster/XHamsterCom.py')
-rw-r--r-- | pyload/plugins/hoster/XHamsterCom.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/pyload/plugins/hoster/XHamsterCom.py b/pyload/plugins/hoster/XHamsterCom.py index 866c5da45..cbdd818c7 100644 --- a/pyload/plugins/hoster/XHamsterCom.py +++ b/pyload/plugins/hoster/XHamsterCom.py @@ -2,17 +2,20 @@ # -*- coding: utf-8 -*- import re -from module.plugins.Hoster import Hoster from urllib import unquote + +from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads + def clean_json(json_expr): json_expr = re.sub('[\n\r]', '', json_expr) json_expr = re.sub(' +', '', json_expr) - json_expr = re.sub('\'','"', json_expr) + json_expr = re.sub('\'', '"', json_expr) return json_expr - + + class XHamsterCom(Hoster): __name__ = "XHamsterCom" __type__ = "hoster" @@ -23,16 +26,16 @@ class XHamsterCom(Hoster): def setup(self): self.html = None - + def process(self, pyfile): self.pyfile = pyfile - + if not self.file_exists(): self.offline() if self.getConfig("type"): - self.desired_fmt = self.getConfig("type") - + self.desired_fmt = self.getConfig("type") + self.pyfile.name = self.get_file_name() + self.desired_fmt self.download(self.get_file_url()) @@ -45,32 +48,31 @@ class XHamsterCom(Hoster): """ if self.html is None: self.download_html() - + flashvar_pattern = re.compile('flashvars = ({.*?});', re.DOTALL) - json_flashvar=flashvar_pattern.search(self.html) + json_flashvar = flashvar_pattern.search(self.html) if json_flashvar is None: self.fail("Parse error (flashvars)") j = clean_json(json_flashvar.group(1)) flashvars = json_loads(j) - + if flashvars["srv"]: - srv_url = flashvars["srv"] + '/' + srv_url = flashvars["srv"] + '/' else: self.fail("Parse error (srv_url)") - + if flashvars["url_mode"]: - url_mode = flashvars["url_mode"] + url_mode = flashvars["url_mode"] else: self.fail("Parse error (url_mode)") - if self.desired_fmt == ".mp4": file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) if file_url is None: self.fail("Parse error (file_url)") - file_url=file_url.group(1) + file_url = file_url.group(1) long_url = srv_url + file_url self.logDebug(_("long_url: %s") % long_url) else: @@ -79,15 +81,14 @@ class XHamsterCom(Hoster): else: self.fail("Parse error (file_url)") - if url_mode=='3': + if url_mode == '3': long_url = file_url self.logDebug(_("long_url: %s") % long_url) - else: + else: long_url = srv_url + "key=" + file_url self.logDebug(_("long_url: %s") % long_url) - + return long_url - def get_file_name(self): if self.html is None: |