summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-11-16 22:13:18 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-11-16 22:13:18 +0100
commit0b3dc1d0243d1c8db633f2ba439ae51ffdc5f3a3 (patch)
tree071af30e6802335dea0cd3a4d53f3ef8381449c8 /module
parentupdate fshare.vn, update hellshare.cz account (diff)
downloadpyload-0b3dc1d0243d1c8db633f2ba439ae51ffdc5f3a3.tar.xz
Contributed plugins - closed #722,#723
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hoster/FileshareInUa.py78
-rw-r--r--module/plugins/hoster/ShareplaceCom.py84
-rw-r--r--module/plugins/hoster/XHamsterCom.py120
3 files changed, 282 insertions, 0 deletions
diff --git a/module/plugins/hoster/FileshareInUa.py b/module/plugins/hoster/FileshareInUa.py
new file mode 100644
index 000000000..9700b2d0a
--- /dev/null
+++ b/module/plugins/hoster/FileshareInUa.py
@@ -0,0 +1,78 @@
+from urllib import urlencode
+import re
+from module.plugins.Hoster import Hoster
+from module.network.RequestFactory import getURL
+from module.utils import parseFileSize
+
+class FileshareInUa(Hoster):
+ __name__ = "FileshareInUa"
+ __type__ = "hoster"
+ __pattern__ = r"http://(?:\w*\.)*?fileshare.in.ua/[A-Za-z0-9]+"
+ __version__ = "0.01"
+ __description__ = """fileshare.in.ua hoster plugin"""
+ __author_name__ = ("fwannmacher")
+ __author_mail__ = ("felipe@warhammerproject.com")
+
+ HOSTER_NAME = "fileshare.in.ua"
+ PATTERN_FILENAME = r'<h3 class="b-filename">(.*?)</h3>'
+ PATTERN_FILESIZE = r'<b class="b-filesize">(.*?)</b>'
+ PATTERN_OFFLINE = "This file doesn't exist, or has been removed."
+
+ def setup(self):
+ self.resumeDownload = True
+ self.multiDL = True
+
+ def process(self, pyfile):
+ self.pyfile = pyfile
+ self.html = self.load(pyfile.url, decode=True)
+
+ if not self._checkOnline():
+ self.offline()
+
+ self.pyfile.name = self._getName()
+
+ self.link = self._getLink()
+
+ if not self.link.startswith('http://'):
+ self.link = "http://fileshare.in.ua" + self.link
+
+ self.download(self.link)
+
+ def _checkOnline(self):
+ if re.search(self.PATTERN_OFFLINE, self.html):
+ return False
+ else:
+ return True
+
+ def _getName(self):
+ name = re.search(self.PATTERN_FILENAME, self.html)
+ if name is None:
+ self.fail("%s: Plugin broken." % self.__name__)
+
+ return name.group(1)
+
+ def _getLink(self):
+ return re.search("<a href=\"(/get/.+)\" class=\"b-button m-blue m-big\" >", self.html).group(1)
+
+def getInfo(urls):
+ result = []
+
+ for url in urls:
+ html = getURL(url)
+
+ if re.search(FileshareInUa.PATTERN_OFFLINE, html):
+ result.append((url, 0, 1, url))
+ else:
+ name = re.search(FileshareInUa.PATTERN_FILENAME, html)
+
+ if name is None:
+ result.append((url, 0, 1, url))
+ continue
+
+ name = name.group(1)
+ size = re.search(FileshareInUa.PATTERN_FILESIZE, html)
+ size = parseFileSize(size.group(1))
+
+ result.append((name, size, 3, url))
+
+ yield result
diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py
new file mode 100644
index 000000000..7f0dee0e5
--- /dev/null
+++ b/module/plugins/hoster/ShareplaceCom.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+import urllib
+from module.plugins.Hoster import Hoster
+
+class ShareplaceCom(Hoster):
+ __name__ = "ShareplaceCom"
+ __type__ = "hoster"
+ __pattern__ = r"(http://)?(www\.)?shareplace\.(com|org)/\?[a-zA-Z0-9]+"
+ __version__ = "0.1"
+ __description__ = """Shareplace.com Download Hoster"""
+ __author_name__ = ("ACCakut, based on YourfilesTo by jeix and skydancer")
+ __author_mail__ = ("none")
+
+ def setup(self):
+ self.html = None
+ self.multiDL = True
+
+ def process(self,pyfile):
+ self.pyfile = pyfile
+ self.prepare()
+ self.download(self.get_file_url())
+
+ def prepare(self):
+ if not self.file_exists():
+ self.offline()
+
+ self.pyfile.name = self.get_file_name()
+
+ wait_time = self.get_waiting_time()
+ self.setWait(wait_time)
+ self.log.debug("%s: Waiting %d seconds." % (self.__name__,wait_time))
+ self.wait()
+
+ def get_waiting_time(self):
+ if self.html is None:
+ self.download_html()
+
+ #var zzipitime = 15;
+ m = re.search(r'var zzipitime = (\d+);', self.html)
+ if m:
+ sec = int(m.group(1))
+ else:
+ sec = 0
+
+ return sec
+
+ def download_html(self):
+ url = re.sub("shareplace.com\/\?", "shareplace.com//index1.php/?a=", self.pyfile.url)
+ self.html = self.load(url, decode=True)
+
+ def get_file_url(self):
+ """ returns the absolute downloadable filepath
+ """
+ url = re.search(r"var beer = '(.*?)';", self.html)
+ if url:
+ url = url.group(1)
+ url = urllib.unquote(url.replace("http://http:/", "").replace("vvvvvvvvv", "").replace("lllllllll", "").replace("teletubbies", ""))
+ self.logDebug("URL: %s" % url)
+ return url
+ else:
+ self.fail("absolute filepath could not be found. offline? ")
+
+ def get_file_name(self):
+ if self.html is None:
+ self.download_html()
+
+ return re.search("<title>\s*(.*?)\s*</title>", self.html).group(1)
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html is None:
+ self.download_html()
+
+ if re.search(r"HTTP Status 404", self.html) is not None:
+ return False
+ else:
+ return True
+
+
+
diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py
new file mode 100644
index 000000000..f4b8c28e1
--- /dev/null
+++ b/module/plugins/hoster/XHamsterCom.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+from urllib import unquote
+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)
+
+ return json_expr
+
+class XHamsterCom(Hoster):
+ __name__ = "XHamsterCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(www\.)?xhamster\.com/movies/.+"
+ __version__ = "0.1"
+ __config__ = [("type", ".mp4;.flv", "Preferred type", ".mp4")]
+ __description__ = """XHamster.com Video Download 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.getConf("type")
+
+ self.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 self.html is None:
+ self.download_html()
+
+ flashvar_pattern = re.compile('flashvars = ({.*?});', re.DOTALL)
+ 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"] + '/'
+ else:
+ self.fail("Parse error (srv_url)")
+
+ if 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)
+ long_url = srv_url + file_url
+ self.logDebug(_("long_url: %s") % long_url)
+ else:
+ if flashvars["file"]:
+ file_url = unquote(flashvars["file"])
+ else:
+ self.fail("Parse error (file_url)")
+
+ if url_mode=='3':
+ long_url = file_url
+ self.logDebug(_("long_url: %s") % long_url)
+ 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:
+ self.download_html()
+
+ file_name_pattern = r"<title>(.*?) - xHamster\.com</title>"
+ file_name = re.search(file_name_pattern, self.html)
+ if file_name is None:
+ file_name_pattern = r"<h1 >(.*)</h1>"
+ file_name = re.search(file_name_pattern, self.html)
+ if file_name is None:
+ file_name_pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?"
+ file_name = re.search(file_name_pattern, self.pyfile.url)
+ if file_name is None:
+ file_name_pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>"
+ file_name = re.search(file_name_pattern, self.html)
+ if file_name is None:
+ return "Unknown"
+
+ return file_name.group(1)
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html is None:
+ self.download_html()
+ if re.search(r"(.*Video not found.*)", self.html) is not None:
+ return False
+ else:
+ return True