diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-02-16 21:59:10 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-02-16 21:59:10 +0100 |
commit | 8e7d14bae4d3c836f029a1235eb227380acc3f75 (patch) | |
tree | ebd0679642cccb994e70a89a106b394189cb28bc /module/plugins/hoster/XHamsterCom.py | |
parent | Merge branch 'stable' into 0.4.10 (diff) | |
download | pyload-8e7d14bae4d3c836f029a1235eb227380acc3f75.tar.xz |
Fix plugins to work on 0.4.10
Diffstat (limited to 'module/plugins/hoster/XHamsterCom.py')
-rw-r--r-- | module/plugins/hoster/XHamsterCom.py | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py deleted file mode 100644 index 92340152f..000000000 --- a/module/plugins/hoster/XHamsterCom.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urllib import unquote - -from pyload.utils import json_loads -from pyload.plugin.Hoster import Hoster - - -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) - - return json_expr - - -class XHamsterCom(Hoster): - __name__ = "XHamsterCom" - __type__ = "hoster" - __version__ = "0.12" - - __pattern__ = r'http://(?:www\.)?xhamster\.com/movies/.+' - __config__ = [("type", ".mp4;.flv", "Preferred type", ".mp4")] - - __description__ = """XHamster.com hoster plugin""" - __license__ = "GPLv3" - __authors__ = [] - - - def process(self, pyfile): - self.pyfile = pyfile - - if not self.file_exists(): - self.offline() - - if self.getConfig("type"): - self.desired_fmt = self.getConfig("type") - - pyfile.name = self.get_file_name() + self.desired_fmt - self.download(self.get_file_url()) - - - def download_html(self): - url = self.pyfile.url - self.html = self.load(url) - - - def get_file_url(self): - """ returns the absolute downloadable filepath - """ - if not self.html: - self.download_html() - - flashvar_pattern = re.compile('flashvars = ({.*?});', re.S) - json_flashvar = flashvar_pattern.search(self.html) - - if not json_flashvar: - self.error(_("flashvar not found")) - - j = clean_json(json_flashvar.group(1)) - flashvars = json_loads(j) - - if flashvars['srv']: - srv_url = flashvars['srv'] + '/' - else: - self.error(_("srv_url not found")) - - if flashvars['url_mode']: - url_mode = flashvars['url_mode'] - - - else: - self.error(_("url_mode not found")) - - if self.desired_fmt == ".mp4": - file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) - if file_url is None: - self.error(_("file_url not found")) - file_url = file_url.group(1) - long_url = srv_url + file_url - self.logDebug("long_url = " + long_url) - else: - if flashvars['file']: - file_url = unquote(flashvars['file']) - else: - self.error(_("file_url not found")) - - if url_mode == '3': - long_url = file_url - self.logDebug("long_url = " + long_url) - else: - long_url = srv_url + "key=" + file_url - self.logDebug("long_url = " + long_url) - - return long_url - - - def get_file_name(self): - if not self.html: - self.download_html() - - pattern = r'<title>(.*?) - xHamster\.com</title>' - name = re.search(pattern, self.html) - if name is None: - pattern = r'<h1 >(.*)</h1>' - name = re.search(pattern, self.html) - if name is None: - pattern = r'http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?' - name = re.match(file_name_pattern, self.pyfile.url) - if name is None: - pattern = r'<div id="element_str_id" style="display:none;">(.*)</div>' - name = re.search(pattern, self.html) - if name is None: - return "Unknown" - - return name.group(1) - - - def file_exists(self): - """ returns True or False - """ - if not self.html: - self.download_html() - if re.search(r"(.*Video not found.*)", self.html) is not None: - return False - else: - return True |