diff options
Diffstat (limited to 'core/module/plugins/hoster')
24 files changed, 2152 insertions, 0 deletions
diff --git a/core/module/plugins/hoster/BasePlugin.py b/core/module/plugins/hoster/BasePlugin.py new file mode 100644 index 000000000..09545d493 --- /dev/null +++ b/core/module/plugins/hoster/BasePlugin.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class BasePlugin(Hoster): + __name__ = "BasePlugin" + __type__ = "hoster" + __pattern__ = r"^unmatchable$" + __version__ = "0.1" + __description__ = """Base Plugin when any other didnt fit""" + __author_name__ = ("RaNaN") + __author_mail__ = ("RaNaN@pyload.org") + + def process(self, pyfile): + """main function""" + + if pyfile.url.startswith("http://"): + + pyfile.name = re.findall("([^\/=]+)", pyfile.url)[-1] + self.download(pyfile.url) + + else: + self.fail("No Plugin matched and not a downloadable url.")
\ No newline at end of file diff --git a/core/module/plugins/hoster/DepositfilesCom.py b/core/module/plugins/hoster/DepositfilesCom.py new file mode 100644 index 000000000..c91341887 --- /dev/null +++ b/core/module/plugins/hoster/DepositfilesCom.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +import urllib +from module.plugins.Hoster import Hoster + +class DepositfilesCom(Hoster): + __name__ = "DepositfilesCom" + __type__ = "hoster" + __pattern__ = r"http://[\w\.]*?depositfiles\.com(/\w{1,3})?/files/[\w]+" + __version__ = "0.1" + __description__ = """Depositfiles.com Download Hoster""" + __author_name__ = ("spoob") + __author_mail__ = ("spoob@pyload.org") + + def setup(self): + self.req.canContinue = self.multiDL = True if self.account else False + + def process(self, pyfile): + self.html = self.load(self.pyfile.url, cookies=False if self.account else False) + + if re.search(r"Such file does not exist or it has been removed for infringement of copyrights", self.html): + self.offline() + + if not self.account: + self.handleFree() + + pyfile.name = re.search('File name: <b title="(.*)">', self.html).group(1) + + link = urllib.unquote(re.search('<form action="(http://.+?\.depositfiles.com/.+?)" method="get"', self.html).group(1)) + self.download(link) + + def handleFree(self): + if re.search(r'File is checked, please try again in a minute.', self.html) != None: + self.log.info("DepositFiles.com: The file is being checked. Waiting 1 minute.") + self.setWait(61) + self.wait() + + if re.search(r'Such file does not exist or it has been removed for infringement of copyrights', self.html) != None: + self.offline() + + self.html = self.load(self.pyfile.url, post={"gateway_result":"1"}) + wait_time = int(re.search(r'<span id="download_waiter_remain">(.*?)</span>', self.html).group(1)) + self.setWait(wait_time) + self.log.debug("DepositFiles.com: Waiting %d seconds." % wait_time) diff --git a/core/module/plugins/hoster/FileserveCom.py b/core/module/plugins/hoster/FileserveCom.py new file mode 100644 index 000000000..ff09d9a0a --- /dev/null +++ b/core/module/plugins/hoster/FileserveCom.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+from module.plugins.ReCaptcha import ReCaptcha + +from module.network.Request import getURL
+ +def getInfo(urls): + result = [] + + for url in urls: + html = getURL(url)
+ if re.search(r'<h1>File not available</h1>', html):
+ result.append((url, 0, 1, url)) + continue + + size = re.search(r"<span><strong>(.*?) MB</strong>", html).group(1)
+ size = int(float(size)*1024*1024) +
+ name = re.search('<h1>(.*?)<br/></h1>', html).group(1) + result.append((name, size, 2, url)) + + yield result +
+class FileserveCom(Hoster):
+ __name__ = "FileserveCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(www\.)?fileserve\.com/file/.*?(/.*)?"
+ __version__ = "0.2"
+ __description__ = """Fileserve.Com File Download Hoster"""
+ __author_name__ = ("jeix", "mkaay")
+ __author_mail__ = ("jeix@hasnomail.de", "mkaay@mkaay.de")
+
+ def setup(self):
+ self.req.canContinue = self.multiDL = True if self.account else False
+
+ def process(self, pyfile):
+
+ self.html = self.load(self.pyfile.url, cookies=False if self.account else True)
+ if re.search(r'<h1>File not available</h1>', self.html) != None:
+ self.offline
+
+ self.pyfile.name = re.search('<h1>(.*?)<br/></h1>', self.html).group(1)
+ + if self.account: + self.handlePremium() + else: + self.handleFree() + + def handlePremium(self): + self.download(self.pyfile.url, post={"download":"premium"}, cookies=True) + + def handleFree(self): +
+ if r'<div id="captchaArea" style="display:none;">' in self.html or \
+ r'/showCaptcha\(\);' in self.html:
+ # we got a captcha
+ id = re.search(r"var reCAPTCHA_publickey='(.*?)';", self.html).group(1)
+ recaptcha = ReCaptcha(self)
+ challenge, code = recaptcha.challenge(id)
+
+ shortencode = re.search(r'name="recaptcha_shortencode_field" value="(.*?)"', self.html).group(1)
+
+ self.html = self.load(r'http://www.fileserve.com/checkReCaptcha.php', post={'recaptcha_challenge_field':challenge,
+ 'recaptcha_response_field':code, 'recaptcha_shortencode_field': shortencode})
+
+ if r'incorrect-captcha-sol' in self.html:
+ self.retry()
+
+ html = self.load(self.pyfile.url, post={"downloadLink":"wait"})
+
+ wait_time = 30
+ m = re.search(r'<span>(.*?)\sSekunden</span>', html)
+ if m != None:
+ wait_time = int( m.group(1).split('.')[0] ) + 1
+
+ m = re.search(r'You need to wait (.*?) seconds to start another download.', html)
+ if m != None:
+ wait_time = int( m.group(1) )
+ self.wantReconnect = True
+
+ if r'Your download link has expired.' in html:
+ self.retry()
+
+ self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait_time))
+ self.setWait(wait_time)
+ self.wait()
+
+ self.load(self.pyfile.url, post={"downloadLink":"show"})
+
+ self.download(self.pyfile.url, post={"download":"normal"})
diff --git a/core/module/plugins/hoster/FreakshareNet.py b/core/module/plugins/hoster/FreakshareNet.py new file mode 100644 index 000000000..1bb36737e --- /dev/null +++ b/core/module/plugins/hoster/FreakshareNet.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster +from time import time + + +class FreakshareNet(Hoster): + __name__ = "FreakshareNet" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?freakshare\.net/files/\S*?/" + __version__ = "0.2" + __description__ = """Freakshare.com Download Hoster""" + __author_name__ = ("sitacuisses","spoob","mkaay") + __author_mail__ = ("sitacuisses@yahoo.de","spoob@pyload.org","mkaay@mkaay.de") + + def setup(self): + self.html = None + self.wantReconnect = False + self.multiDL = False + self.req_opts = [] + + def process(self, pyfile): + self.pyfile = pyfile + self.prepare() + self.get_file_url() + + self.download(self.pyfile.url, post=self.req_opts) + + + def prepare(self): + pyfile = self.pyfile + + self.wantReconnect = False + + self.download_html() + + if not self.file_exists(): + self.offline + + self.setWait( self.get_waiting_time() ) + + pyfile.name = self.get_file_name() + + self.wait() + + return True + + def download_html(self): + url = self.pyfile.url + self.html = self.load(url, cookies=True) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + if not self.wantReconnect: + self.req_opts = self.get_download_options() # get the Post options for the Request + #file_url = self.pyfile.url + #return file_url + else: + self.offline() + + def get_file_name(self): + if self.html == None: + self.download_html() + if not self.wantReconnect: + file_name = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center\;\">([^ ]+)", self.html).group(1) + return file_name + else: + return self.pyfile.url + + def get_waiting_time(self): + if self.html == None: + self.download_html() + timestring = re.search('\s*var\stime\s=\s(\d*?)\.\d*;', self.html).group(1) + if timestring: + sec = int(timestring) + 1 #add 1 sec as tenths of seconds are cut off + else: + sec = 0 + return sec + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + if re.search(r"Sorry, this Download doesnt exist anymore", self.html) != None: + return False + else: + return True + + def get_download_options(self): + re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>", self.html).group(0) #get the whole request + to_sort = re.findall(r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>", re_envelope) + request_options = [] + + for item in to_sort: #Name value pairs are output reversed from regex, so we reorder them + request_options.append((item[1], item[0])) + + herewego = self.load(self.pyfile.url, None, request_options, cookies=True) # the actual download-Page + + to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego) + request_options = [] + + for item in to_sort: #Same as above + request_options.append((item[1], item[0])) + + return request_options
\ No newline at end of file diff --git a/core/module/plugins/hoster/Ftp.py b/core/module/plugins/hoster/Ftp.py new file mode 100644 index 000000000..9303b00c8 --- /dev/null +++ b/core/module/plugins/hoster/Ftp.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*-
+
+"""
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: jeix + @author: mkaay
+"""
+
+import logging
+from os.path import exists
+from os.path import join
+from os.path import exists
+from os import makedirs
+import sys
+
+from module.plugins.Hoster import Hoster
+
+
+class Ftp(Hoster):
+ __name__ = "Ftp"
+ __version__ = "0.3"
+ __pattern__ = r'ftp://(.*?:.*?@)?.*?/.*' # ftp://user:password@ftp.server.org/path/to/file
+ __type__ = "hoster"
+ __description__ = """A Plugin that allows you to download from an from an ftp directory"""
+ __author_name__ = ("jeix", "mkaay")
+ __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de")
+
+ def process(self, pyfile):
+ self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="FTP")
+ pyfile.name = self.pyfile.url.rpartition('/')[2]
+
+ self.doDownload(pyfile.url, pyfile.name)
+
+ def doDownload(self, url, filename):
+ self.pyfile.setStatus("downloading")
+
+ download_folder = self.core.config['general']['download_folder']
+ location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
+ if not exists(location):
+ makedirs(location)
+
+ newname = self.req.download(str(url), join(location, filename.decode(sys.getfilesystemencoding())))
+ self.pyfile.size = self.req.dl_size
+
+ if newname:
+ self.pyfile.name = newname
diff --git a/core/module/plugins/hoster/HotfileCom.py b/core/module/plugins/hoster/HotfileCom.py new file mode 100644 index 000000000..8f231fcd5 --- /dev/null +++ b/core/module/plugins/hoster/HotfileCom.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import time +from module.plugins.Hoster import Hoster +from module.plugins.ReCaptcha import ReCaptcha + +from module.network.Request import getURL +from module.plugins.Plugin import chunks + +def getInfo(urls): + api_url_base = "http://api.hotfile.com/" + + for chunk in chunks(urls, 90): + api_param_file = {"action":"checklinks","links": ",".join(chunk),"fields":"id,status,name,size"} #api only supports old style links + src = getURL(api_url_base, post=api_param_file) + result = [] + for i, res in enumerate(src.split("\n")): + if not res: + continue + fields = res.split(",") + + if fields[1] in ("1", "2"): + status = 2 + elif fields[1]: + status = 1 + + result.append((fields[2], int(fields[3]), status, chunk[i])) + yield result + +class HotfileCom(Hoster): + __name__ = "HotfileCom" + __type__ = "hoster" + __pattern__ = r"http://hotfile.com/dl/" + __version__ = "0.3" + __description__ = """Hotfile.com Download Hoster""" + __author_name__ = ("sitacuisses","spoob","mkaay") + __author_mail__ = ("sitacuisses@yhoo.de","spoob@pyload.org","mkaay@mkaay.de") + + def setup(self): + self.html = [None, None] + self.wantReconnect = False + self.multiDL = False + self.htmlwithlink = None + self.url = None + + if self.account: + self.multiDL = True + self.req.canContinue = True + + def apiCall(self, method, post, login=False): + if not self.account and login: + return + elif self.account and login: + return self.account.apiCall(method, post) + post.update({"action": method}) + return self.load("http://api.hotfile.com/", post=post) + + def process(self, pyfile): + self.wantReconnect = False + + args = {"links":self.pyfile.url, "fields":"id,status,name,size,sha1"} + resp = self.apiCall("checklinks", args) + self.apiData = {} + for k, v in zip(args["fields"].split(","), resp.strip().split(",")): + self.apiData[k] = v + + if self.apiData["status"] == "0": + self.offline() + + pyfile.name = self.apiData["name"] + + if not self.account: + self.downloadHTML() + + self.setWait(self.getWaitTime()) + self.wait() + + self.freeDownload() + else: + dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}) + self.download(dl) + + def downloadHTML(self): + self.html[0] = self.load(self.pyfile.url, get={"lang":"en"}, cookies=True) + + def freeDownload(self): + + form_content = re.search(r"<form style=.*(\n<.*>\s*)*?\n<tr>", self.html[0]).group(0) + form_posts = re.findall(r"<input\stype=hidden\sname=(\S*)\svalue=(\S*)>", form_content) + + self.html[1] = self.load(self.pyfile.url, post=form_posts, cookies=True) + + re_captcha = ReCaptcha(self) + + challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1]) + + if challenge: + challenge, result = re_captcha.challenge(challenge.group(1)) + + url = re.search(r'<form action="(/dl/[^"]+)', self.html[1] ) + + self.html[1] = self.load("http://hotfile.com"+url.group(1), post={"action": "checkcaptcha", + "recaptcha_challenge_field" : challenge, + "recaptcha_response_field": result}) + + if "Wrong Code. Please try again." in self.html[1]: + self.freeDownload() + return + + file_url = re.search(r'a href="(http://hotfile\.com/get/\S*?)"', self.html[1]).group(1) + self.download(file_url) + + def getWaitTime(self): + free_limit_pattern = re.compile(r"timerend=d\.getTime\(\)\+(\d+);") + matches = free_limit_pattern.findall(self.html[0]) + if matches: + for match in matches: + if int(match) == 60000: + continue + if int(match) == 0: + continue + else: + self.wantReconnect = True + return int(match)/1000 + 65 + return 65 diff --git a/core/module/plugins/hoster/MegauploadCom.py b/core/module/plugins/hoster/MegauploadCom.py new file mode 100644 index 000000000..a14c2c76f --- /dev/null +++ b/core/module/plugins/hoster/MegauploadCom.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re + +from module.plugins.Hoster import Hoster + +from module.network.Request import getURL + +def getInfo(urls): + url = "http://megaupload.com/mgr_linkcheck.php" + + ids = [x.split("=")[-1] for x in urls] + + i = 0 + post = {} + for id in ids: + post["id%i"%i] = id + i += 1 + + api = getURL(url, {}, post) + api = [x.split("&") for x in re.split(r"&?(?=id[\d]+=)", api)] + + result = [] + i=0 + for data in api: + if data[0].startswith("id"): + tmp = [x.split("=") for x in data] + if tmp[2][1] == "3": + status = 3 + elif tmp[0][1] == "0": + status = 2 + elif tmp[0][1] == "1": + status = 1 + else: + status = 3 + + name = tmp[3][1] + size = tmp[1][1] + + result.append( (name, size, status, urls[i] ) ) + i += 1 + + yield result + +class MegauploadCom(Hoster): + __name__ = "MegauploadCom" + __type__ = "hoster" + __pattern__ = r"http://[\w\.]*?(megaupload)\.com/.*?(\?|&)d=[0-9A-Za-z]+" + __version__ = "0.1" + __description__ = """Megaupload.com Download Hoster""" + __author_name__ = ("spoob") + __author_mail__ = ("spoob@pyload.org") + + def setup(self): + self.html = [None, None] + self.multiDL = False + + def process(self, pyfile): + self.pyfile = pyfile + self.download_html() + if not self.file_exists(): + self.offline() + + self.setWait(45) + self.wait() + + pyfile.name = self.get_file_name() + self.download(self.get_file_url()) + + def download_html(self): + for i in range(5): + self.html[0] = self.load(self.pyfile.url) + try: + url_captcha_html = re.search('(http://www.{,3}\.megaupload\.com/gencap.php\?.*\.gif)', self.html[0]).group(1) + except: + continue + + captcha = self.decryptCaptcha(url_captcha_html) + captchacode = re.search('name="captchacode" value="(.*)"', self.html[0]).group(1) + megavar = re.search('name="megavar" value="(.*)">', self.html[0]).group(1) + self.html[1] = self.load(self.pyfile.url, post={"captcha": captcha, "captchacode": captchacode, "megavar": megavar}) + if re.search(r"Waiting time before each download begins", self.html[1]) != None: + break + + def get_file_url(self): + file_url_pattern = 'id="downloadlink"><a href="(.*)" onclick="' + search = re.search(file_url_pattern, self.html[1]) + return search.group(1).replace(" ", "%20") + + def get_file_name(self): + file_name_pattern = 'id="downloadlink"><a href="(.*)" onclick="' + return re.search(file_name_pattern, self.html[1]).group(1).split("/")[-1] + + def file_exists(self): + self.download_html() + if re.search(r"Unfortunately, the link you have clicked is not available.", self.html[0]) != None or \ + re.search(r"Download limit exceeded", self.html[0]): + return False + return True diff --git a/core/module/plugins/hoster/MegavideoCom.py b/core/module/plugins/hoster/MegavideoCom.py new file mode 100644 index 000000000..7ea045447 --- /dev/null +++ b/core/module/plugins/hoster/MegavideoCom.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import time +from module.plugins.Hoster import Hoster +from module.unescape import unescape + +class MegavideoCom(Hoster): + __name__ = "MegavideoCom" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?megavideo.com/\?v=.*" + __version__ = "0.1" + __description__ = """Megavideo.com Download Hoster""" + __author_name__ = ("jeix","mkaay") + __author_mail__ = ("jeix@hasnomail.de","mkaay@mkaay.de") + + def __init__(self, parent): + Hoster.__init__(self, parent) + self.parent = parent + self.html = None + + def download_html(self): + url = self.parent.url + self.html = self.req.load(url) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + + # get id + id = re.search("previewplayer/\\?v=(.*?)&width", self.html).group(1) + + # check for hd link and return if there + if "flashvars.hd = \"1\";" in self.html: + content = self.req.load("http://www.megavideo.com/xml/videolink.php?v=%s" % id) + return unescape(re.search("hd_url=\"(.*?)\"", content).group(1)) + + # else get normal link + s = re.search("flashvars.s = \"(\\d+)\";", self.html).group(1) + un = re.search("flashvars.un = \"(.*?)\";", self.html).group(1) + k1 = re.search("flashvars.k1 = \"(\\d+)\";", self.html).group(1) + k2 = re.search("flashvars.k2 = \"(\\d+)\";", self.html).group(1) + return "http://www%s.megavideo.com/files/%s/" % (s, self.__decrypt(un, int(k1), int(k2))) + + def __decrypt(self, input, k1, k2): + req1 = [] + req3 = 0 + for c in input: + c = int(c, 16) + tmp = "".join([str((c >> y) & 1) for y in range(4 -1, -1, -1)]) + req1.extend([int(x) for x in tmp]) + + req6 = [] + req3 = 0 + while req3 < 384: + k1 = (k1 * 11 + 77213) % 81371 + k2 = (k2 * 17 + 92717) % 192811 + req6.append((k1 + k2) % 128) + req3 += 1 + + req3 = 256 + while req3 >= 0: + req5 = req6[req3] + req4 = req3 % 128 + req8 = req1[req5] + req1[req5] = req1[req4] + req1[req4] = req8 + req3 -= 1 + + req3 = 0 + while req3 < 128: + req1[req3] = req1[req3] ^ (req6[req3+256] & 1) + req3 += 1 + + out = "" + req3 = 0 + while req3 < len(req1): + tmp = req1[req3] * 8 + tmp += req1[req3+1] * 4 + tmp += req1[req3+2] * 2 + tmp += req1[req3+3] + + out += "%X" % tmp + + req3 += 4 + + return out.lower() + + def get_file_name(self): + if self.html == None: + self.download_html() + + name = re.search("flashvars.title = \"(.*?)\";", self.html).group(1) + name = "%s.flv" % unescape(name.encode("ascii", "ignore")).decode("utf-8").encode("ascii", "ignore").replace("+", " ") + return name + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + + if re.search(r"Dieses Video ist nicht verfügbar.", self.html) != None or \ + re.search(r"This video is unavailable.", self.html) != None: + return False + else: + return True + diff --git a/core/module/plugins/hoster/MyvideoDe.py b/core/module/plugins/hoster/MyvideoDe.py new file mode 100644 index 000000000..f2d2082a7 --- /dev/null +++ b/core/module/plugins/hoster/MyvideoDe.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster +from module.unescape import unescape + +class MyvideoDe(Hoster): + __name__ = "MyvideoDe" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?myvideo.de/watch/" + __version__ = "0.9" + __description__ = """Myvideo.de Video Download Hoster""" + __author_name__ = ("spoob") + __author_mail__ = ("spoob@pyload.org") + + def setup(self): + self.html = None + + def process(self, pyfile): + self.pyfile = pyfile + self.download_html() + pyfile.name = self.get_file_name() + self.download(self.get_file_url()) + + def download_html(self): + self.html = self.load(self.pyfile.url) + + def get_file_url(self): + videoId = re.search(r"addVariable\('_videoid','(.*)'\);p.addParam\('quality'", self.html).group(1) + videoServer = re.search("rel='image_src' href='(.*)thumbs/.*' />", self.html).group(1) + file_url = videoServer + videoId + ".flv" + return file_url + + def get_file_name(self): + file_name_pattern = r"<h1 class='globalHd'>(.*)</h1>" + return unescape(re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.flv') + + def file_exists(self): + self.download_html() + self.load(str(self.pyfile.url), cookies=False, just_header=True) + if self.req.lastEffectiveURL == "http://www.myvideo.de/": + return False + return True diff --git a/core/module/plugins/hoster/NetloadIn.py b/core/module/plugins/hoster/NetloadIn.py new file mode 100644 index 000000000..6f0cb9461 --- /dev/null +++ b/core/module/plugins/hoster/NetloadIn.py @@ -0,0 +1,212 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import sleep + + +from module.plugins.Hoster import Hoster +from module.network.Request import getURL +from module.plugins.Plugin import chunks + + + +def getInfo(urls): + ## returns list of tupels (name, size (in bytes), status (see FileDatabase), url) + + + apiurl = "http://api.netload.in/info.php?auth=Zf9SnQh9WiReEsb18akjvQGqT0I830e8&bz=1&md5=1&file_id=" + id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") + urls_per_query = 80 + + for chunk in chunks(urls, urls_per_query): + ids = "" + for url in chunk: + match = id_regex.search(url) + if match: + ids = ids + match.group(1) +";" + + api = getURL(apiurl+ids) + + if api == None or len(api) < 10: + print "Netload prefetch: failed " + return + if api.find("unknown_auth") >= 0: + print "Netload prefetch: Outdated auth code " + return + + result = [] + + for i, r in enumerate(api.split()): + try: + tmp = r.split(";") + try: + size = int(tmp[2]) + except: + size = 0 + result.append( (tmp[1], size, 2 if tmp[3] == "online" else 1, chunk[i] ) ) + except: + print "Netload prefetch: Error while processing response: " + print r + + yield result + +class NetloadIn(Hoster): + __name__ = "NetloadIn" + __type__ = "hoster" + __pattern__ = r"http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)" + __version__ = "0.2" + __description__ = """Netload.in Download Hoster""" + __config__ = [ ("dumpgen", "bool", "Generate debug page dumps on stdout", "False") ] + __author_name__ = ("spoob", "RaNaN", "Gregy") + __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "gregy@gregy.cz") + + def setup(self): + self.multiDL = False + if self.account: + self.multiDL = True + self.req.canContinue = True + + def process(self, pyfile): + self.url = pyfile.url + self.prepare() + self.pyfile.setStatus("downloading") + self.proceed(self.url) + + def prepare(self): + self.download_api_data() + + if self.api_data and self.api_data["filename"]: + self.pyfile.name = self.api_data["filename"] + + if self.account: + self.log.debug("Netload: Use Premium Account") + return True + + if self.download_html(): + return True + else: + self.fail("Failed") + return False + + def download_api_data(self): + url = self.url + id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") + match = id_regex.search(url) + if match: + apiurl = "http://netload.in/share/fileinfos2.php" + src = self.load(apiurl, cookies=False, get={"file_id": match.group(1)}) + self.log.debug("Netload: APIDATA: "+src.strip()) + self.api_data = {} + if src == "unknown_server_data": + self.api_data = False + elif not src == "unknown file_data": + + lines = src.split(";") + self.api_data["exists"] = True + self.api_data["fileid"] = lines[0] + self.api_data["filename"] = lines[1] + self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') + self.api_data["status"] = lines[3] + if self.api_data["status"] == "online": + self.api_data["checksum"] = lines[4].strip() + else: + self.offline(); + else: + self.api_data["exists"] = False + else: + self.api_data = False + self.html[0] = self.load(self.url, cookies=False) + + def final_wait(self, page): + wait_time = self.get_wait_time(page) + self.setWait(wait_time) + self.log.debug(_("Netload: final wait %d seconds" % wait_time)) + self.wait() + self.url = self.get_file_url(page) + + def download_html(self): + self.log.debug("Netload: Entering download_html") + page = self.load(self.url, cookies=True) + captchawaited = False + for i in range(10): + self.log.debug(_("Netload: try number %d " % i)) + if self.getConf('dumpgen'): + print page + + if re.search(r"(We will prepare your download..)", page) != None: + self.log.debug("Netload: We will prepare your download") + self.final_wait(page); + return True + if re.search(r"(We had a reqeust with the IP)", page) != None: + wait = self.get_wait_time(page); + if wait == 0: + self.log.debug("Netload: Wait was 0 setting 30") + wait = 30 + self.log.info(_("Netload: waiting between downloads %d s." % wait)) + self.wantReconnect = True + self.setWait(wait) + self.wait() + + link = re.search(r"You can download now your next file. <a href=\"(index.php\?id=10&.*)\" class=\"Orange_Link\">Click here for the download</a>", page) + if link != None: + self.log.debug("Netload: Using new link found on page") + page = self.load("http://netload.in/" + link.group(1).replace("amp;", "")) + else: + self.log.debug("Netload: No new link found, using old one") + page = self.load(self.url, cookies=True) + continue + + + self.log.debug("Netload: Trying to find captcha") + + url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', page).group(1).replace("amp;", "") + page = self.load(url_captcha_html, cookies=True) + + try: + captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', page).group(1) + except: + open("dump.html", "w").write(page) + self.log.debug("Netload: Could not find captcha, try again from begining") + continue + + file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', page).group(1) + if not captchawaited: + wait = self.get_wait_time(page); + self.log.info(_("Netload: waiting for captcha %d s." % wait)) + self.setWait(wait) + self.wait() + captchawaited = True + + captcha = self.decryptCaptcha(captcha_url) + sleep(4) + page = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) + + return False + + + def get_file_url(self, page): + try: + file_url_pattern = r"<a class=\"Orange_Link\" href=\"(http://.+)\" >Click here" + attempt = re.search(file_url_pattern, page) + if attempt != None: + return attempt.group(1) + else: + self.log.debug("Netload: Backup try for final link") + file_url_pattern = r"<a href=\"(.+)\" class=\"Orange_Link\">Click here" + attempt = re.search(file_url_pattern, page) + return "http://netload.in/"+attempt.group(1); + except: + self.log.debug("Netload: Getting final link failed") + return None + + def get_wait_time(self, page): + wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", page).group(1)) / 100 + return wait_seconds + + + def proceed(self, url): + self.log.debug("Netload: Downloading..") + + self.download(url, cookies=True) + diff --git a/core/module/plugins/hoster/PornhostCom.py b/core/module/plugins/hoster/PornhostCom.py new file mode 100644 index 000000000..5dd681b5b --- /dev/null +++ b/core/module/plugins/hoster/PornhostCom.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+
+class PornhostCom(Hoster):
+ __name__ = "PornhostCom"
+ __type__ = "hoster"
+ __pattern__ = r'http://[\w\.]*?pornhost\.com/([0-9]+/[0-9]+\.html|[0-9]+)'
+ __version__ = "0.2"
+ __description__ = """Pornhost.com Download Hoster"""
+ __author_name__ = ("jeix")
+ __author_mail__ = ("jeix@hasnomail.de")
+
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ self.download(self.get_file_url())
+
+
+ ### old interface
+ 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 == None:
+ self.download_html()
+
+ file_url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html)
+ if not file_url:
+ file_url = re.search(r'"(http://dl[0-9]+\.pornhost\.com/files/.*?/.*?/.*?/.*?/.*?/.*?\..*?)"', self.html)
+ if not file_url:
+ file_url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html)
+ if not file_url:
+ file_url = re.search(r'"http://file[0-9]+\.pornhost\.com/[0-9]+/.*?"', self.html) # TODO: fix this one since it doesn't match
+
+ file_url = file_url.group(1).strip()
+
+ return file_url
+
+ def get_file_name(self):
+ if self.html == None:
+ self.download_html()
+
+ name = re.search(r'<title>pornhost\.com - free file hosting with a twist - gallery(.*?)</title>', self.html)
+ if not name:
+ name = re.search(r'id="url" value="http://www\.pornhost\.com/(.*?)/"', self.html)
+ if not name:
+ name = re.search(r'<title>pornhost\.com - free file hosting with a twist -(.*?)</title>', self.html)
+ if not name:
+ name = re.search(r'"http://file[0-9]+\.pornhost\.com/.*?/(.*?)"', self.html)
+
+ name = name.group(1).strip() + ".flv"
+
+ return name
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html == None:
+ self.download_html()
+
+ if re.search(r'gallery not found', self.html) != None \
+ or re.search(r'You will be redirected to', self.html) != None:
+ return False
+ else:
+ return True
+
+
diff --git a/core/module/plugins/hoster/PornhubCom.py b/core/module/plugins/hoster/PornhubCom.py new file mode 100644 index 000000000..ea7e1423c --- /dev/null +++ b/core/module/plugins/hoster/PornhubCom.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+
+class PornhubCom(Hoster):
+ __name__ = "PornhubCom"
+ __type__ = "hoster"
+ __pattern__ = r'http://[\w\.]*?pornhub\.com/view_video\.php\?viewkey=[\w\d]+'
+ __version__ = "0.2"
+ __description__ = """Pornhub.com Download Hoster"""
+ __author_name__ = ("jeix")
+ __author_mail__ = ("jeix@hasnomail.de")
+
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ 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 == None:
+ self.download_html()
+
+ url = "http://www.pornhub.com//gateway.php"
+ video_id = self.pyfile.url.split('=')[-1]
+ # thanks to jD team for this one v
+ post_data = "\x00\x03\x00\x00\x00\x01\x00\x0c\x70\x6c\x61\x79\x65\x72\x43\x6f\x6e\x66\x69\x67\x00\x02\x2f\x31\x00\x00\x00\x44\x0a\x00\x00\x00\x03\x02\x00"
+ post_data += chr(len(video_id))
+ post_data += video_id
+ post_data += "\x02\x00\x02\x2d\x31\x02\x00\x20"
+ post_data += "add299463d4410c6d1b1c418868225f7"
+
+ content = self.req.load(url, post=str(post_data), no_post_encode=True)
+ file_url = re.search(r'flv_url.*(http.*?)\?r=.*', content).group(1)
+
+ return file_url
+
+ def get_file_name(self):
+ if self.html == None:
+ self.download_html()
+
+ name = re.findall('<h1>(.*?)</h1>', self.html)[1] + ".flv"
+
+ return name
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html == None:
+ self.download_html()
+
+ if re.search(r'This video is no longer in our database or is in conversion', self.html) != None:
+ return False
+ else:
+ return True
diff --git a/core/module/plugins/hoster/RapidshareCom.py b/core/module/plugins/hoster/RapidshareCom.py new file mode 100644 index 000000000..fa5f053de --- /dev/null +++ b/core/module/plugins/hoster/RapidshareCom.py @@ -0,0 +1,188 @@ + +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import time + +from module.network.Request import getURL +from module.plugins.Hoster import Hoster +import hashlib + +def getInfo(urls): + + ids = "" + names = "" + + for url in urls: + tmp = url.split("/") + ids+= ","+tmp[-2] + names+= ","+tmp[-1] + + url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=%s&filenames=%s" % (ids[1:], names[1:]) + + + api = getURL(url) + result = [] + i = 0 + for res in api.split(): + tmp = res.split(",") + if tmp[4] in ("0", "4", "5"): status = 1 + elif tmp[4] == "1": status = 2 + else: status = 3 + + result.append( (tmp[1], tmp[2], status, urls[i]) ) + i += 1 + + yield result + +class RapidshareCom(Hoster): + __name__ = "RapidshareCom" + __type__ = "hoster" + __pattern__ = r"http://[\w\.]*?rapidshare.com/files/(\d*?)/(.*)" + __version__ = "1.1" + __description__ = """Rapidshare.com Download Hoster""" + __config__ = [ ("server", "str", "Preferred Server", "None") ] + __author_name__ = ("spoob", "RaNaN", "mkaay") + __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") + + def setup(self): + self.html = [None, None] + self.no_slots = True + self.api_data = None + self.multiDL = False + if self.account: + self.multiDL = True + self.req.canContinue = True + + def process(self, pyfile): + self.url = self.pyfile.url + self.prepare() + self.proceed(self.url) + + def prepare(self): + # self.no_slots = True + # self.want_reconnect = False + + self.download_api_data() + if self.api_data["status"] == "1": + self.pyfile.name = self.get_file_name() + + if self.account: + info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) + self.log.debug(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) + if self.api_data["size"] / 1024 > info["trafficleft"]: + self.log.info(_("%s: Not enough traffic left" % self.__name__)) + self.resetAcount() + else: + self.url = self.api_data["mirror"] + return True + + self.download_html() + while self.no_slots: + self.setWait(self.get_wait_time()) + self.wait() + # self.pyfile.status.waituntil = self.time_plus_wait + # self.pyfile.status.want_reconnect = self.want_reconnect + # thread.wait(self.pyfile) + + self.url = self.get_file_url() + + return True + elif self.api_data["status"] == "2": + self.log.info(_("Rapidshare: Traffic Share (direct download)")) + self.pyfile.name = self.get_file_name() + # self.pyfile.status.url = self.parent.url + return True + else: + self.fail("Unknown response code.") + + def download_api_data(self, force=False): + """ + http://images.rapidshare.com/apidoc.txt + """ + if self.api_data and not force: + return + api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" + api_param_file = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"} + m = re.compile(self.__pattern__).search(self.url) + if m: + api_param_file["files"] = m.group(1) + api_param_file["filenames"] = m.group(2) + src = self.load(api_url_base, cookies=False, get=api_param_file) + if src.startswith("ERROR"): + return + fields = src.split(",") + self.api_data = {} + self.api_data["fileid"] = fields[0] + self.api_data["filename"] = fields[1] + self.api_data["size"] = int(fields[2]) # in bytes + self.api_data["serverid"] = fields[3] + self.api_data["status"] = fields[4] + """ + status codes: + 0=File not found + 1=File OK (Downloading possible without any logging) + 2=File OK (TrafficShare direct download without any logging) + 3=Server down + 4=File marked as illegal + 5=Anonymous file locked, because it has more than 10 downloads already + 6=File OK (TrafficShare direct download with enabled logging) + """ + self.api_data["shorthost"] = fields[5] + self.api_data["checksum"] = fields[6].strip().lower() # md5 + + self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data + + def download_html(self): + """ gets the url from self.parent.url saves html in self.html and parses + """ + self.html[0] = self.load(self.url, cookies=False) + + def get_wait_time(self): + """downloads html with the important informations + """ + file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) + self.html[1] = self.load(file_server_url, cookies=False, post={"dl.start": "Free"}) + + if re.search(r"is already downloading", self.html[1]): + self.log.info(_("Rapidshare: Already downloading, wait 30 minutes")) + return 30 * 60 + self.no_slots = False + try: + wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1) + self.no_slots = True + self.wantReconnect = True + return 60 * int(wait_minutes) + 60 + except: + if re.search(r"(Currently a lot of users|no more download slots|servers are overloaded)", self.html[1], re.I) != None: + self.log.info(_("Rapidshare: No free slots!")) + self.no_slots = True + return time() + 130 + self.no_slots = False + wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1) + return int(wait_seconds) + 5 + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.getConf('server') == "None": + file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" + else: + file_url_pattern = '(http://rs.*)\';" /> %s<br />' % getConf('server') + + return re.search(file_url_pattern, self.html[1]).group(1) + + def get_file_name(self): + if self.api_data["filename"]: + return self.api_data["filename"] + elif self.html[0]: + file_name_pattern = r"<p class=\"downloadlink\">.+/(.+) <font" + file_name_search = re.search(file_name_pattern, self.html[0]) + if file_name_search: + return file_name_search.group(1) + return self.url.split("/")[-1] + + def proceed(self, url): + self.download(url, get={"directstart":1}, cookies=True) + diff --git a/core/module/plugins/hoster/RedtubeCom.py b/core/module/plugins/hoster/RedtubeCom.py new file mode 100644 index 000000000..6a9baffbe --- /dev/null +++ b/core/module/plugins/hoster/RedtubeCom.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+from module.unescape import unescape
+
+class RedtubeCom(Hoster):
+ __name__ = "RedtubeCom"
+ __type__ = "hoster"
+ __pattern__ = r'http://[\w\.]*?redtube\.com/\d+'
+ __version__ = "0.2"
+ __description__ = """Redtube.com Download Hoster"""
+ __author_name__ = ("jeix")
+ __author_mail__ = ("jeix@hasnomail.de")
+
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ 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 == None:
+ self.download_html()
+
+ file_url = unescape(re.search(r'hashlink=(http.*?)"', self.html).group(1))
+
+ return file_url
+
+ def get_file_name(self):
+ if self.html == None:
+ self.download_html()
+
+ name = re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv"
+ return name
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html == None:
+ self.download_html()
+
+ if re.search(r'This video has been removed.', self.html) != None:
+ return False
+ else:
+ return True
+
diff --git a/core/module/plugins/hoster/ShareCx.py b/core/module/plugins/hoster/ShareCx.py new file mode 100644 index 000000000..e64459754 --- /dev/null +++ b/core/module/plugins/hoster/ShareCx.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+from module.plugins.Plugin import chunks
+from module.network.Request import getURL
+#from module.BeautifulSoup import BeautifulSoup
+
+def getInfo(urls):
+ api_url = "http://www.share.cx/uapi?do=check&links="
+
+ for chunk in chunks(urls, 90):
+ get = ""
+ for url in chunk:
+ get += ";"+url
+
+ api = getURL(api_url+get[1:])
+ result = []
+
+ for i, link in enumerate(api.split()):
+ url,name,size = link.split(";")
+ if name and size:
+ status = 2
+ else:
+ status = 1
+
+ if not name: name = chunk[i]
+ if not size: size = 0
+
+ result.append( (name, size, status, chunk[i]) )
+
+ yield result
+
+class ShareCx(Hoster):
+ __name__ = "ShareCx"
+ __type__ = "hoster"
+ __pattern__ = r"http://[\w\.]*?share\.cx/(files|videos)/\d+"
+ __version__ = "0.1"
+ __description__ = """Share.cx Download Hoster"""
+ __author_name__ = ("jeix")
+ __author_mail__ = ("jeix@hasnomail.de")
+
+
+ def setup(self):
+ self.multiDL = False
+
+
+ def process(self, pyfile):
+ self.pyfile = pyfile
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ self.doDownload()
+
+
+ def download_html(self):
+ self.html = self.load(self.pyfile.url)
+
+ def doDownload(self):
+ """ returns the absolute downloadable filepath
+ """
+ if self.html == None:
+ self.download_html()
+
+ op = re.search(r'name="op" value="(.*?)"', self.html).group(1)
+ usr_login = re.search(r'name="usr_login" value="(.*?)"', self.html).group(1)
+ id = re.search(r'name="id" value="(.*?)"', self.html).group(1)
+ fname = re.search(r'name="fname" value="(.*?)"', self.html).group(1)
+ referer = re.search(r'name="referer" value="(.*?)"', self.html).group(1)
+ method_free = "Datei+herunterladen"
+
+ self.html = self.load(self.pyfile.url, post={
+ "op" : op,
+ "usr_login" : usr_login,
+ "id" : id,
+ "fname" : fname,
+ "referer" : referer,
+ "method_free" : method_free
+ })
+
+
+ m = re.search(r'startTimer\((\d+)\)', self.html)
+ if m != None:
+ wait_time = int(m.group(1))
+ self.setWait(wait_time)
+ self.wantReconnect = True
+ self.log.debug("%s: IP blocked wait %d seconds." % (self.__name__, wait_time))
+ self.wait()
+
+ m = re.search(r'countdown">.*?(\d+).*?</span>', self.html)
+ if m == None:
+ m = re.search(r'id="countdown_str".*?<span id=".*?">.*?(\d+).*?</span', self.html)
+ if m != None:
+ wait_time = int(m.group(1))
+ self.setWait(wait_time)
+ self.wantReconnect = False
+ self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait_time))
+ self.wait()
+
+
+ op = re.search(r'name="op" value="(.*?)"', self.html).group(1)
+ id = re.search(r'name="id" value="(.*?)"', self.html).group(1)
+ rand = re.search(r'name="rand" value="(.*?)"', self.html).group(1)
+ referer = re.search(r'name="referer" value="(.*?)"', self.html).group(1)
+ method_free = re.search(r'name="method_free" value="(.*?)"', self.html).group(1)
+ method_premium = re.search(r'name="method_premium" value="(.*?)"', self.html).group(1)
+ down_script = re.search(r'name="down_script" value="(.*?)"', self.html).group(1)
+
+ data = {
+ "op" : op,
+ "id" : id,
+ "rand" : rand,
+ "referer" : referer,
+ "method_free" : method_free,
+ "method_premium" : method_premium,
+ "down_script" : down_script
+ }
+
+ if '/captchas/' in self.html:
+ captcha_url = re.search(r'(http://(?:[\w\d]+\.)?.*?/captchas/.*?)').group(1)
+ captcha = self.decryptCaptcha(captcha_url)
+ data["code"] = captcha
+
+
+ self.download(self.pyfile.url, post=data)
+
+ # soup = BeautifulSoup(html)
+ # form = soup.find("form")
+ # postfields = {}
+ # for input in form,findall("input"):
+ # postfields[input["name"]] = input["value"]
+ # postfields["method_free"] = "Datei herunterladen"
+
+ def get_file_name(self):
+ if self.html == None:
+ self.download_html()
+
+ name = re.search(r'alt="Download" /></span>(.*?)</h3>', self.html).group(1)
+ return name
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html == None:
+ self.download_html()
+
+ if re.search(r'File not found<br>It was deleted due to inactivity or abuse request', self.html) != None:
+ return False
+
+ return True
+
+
diff --git a/core/module/plugins/hoster/ShareonlineBiz.py b/core/module/plugins/hoster/ShareonlineBiz.py new file mode 100644 index 000000000..bc1951602 --- /dev/null +++ b/core/module/plugins/hoster/ShareonlineBiz.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import os.path +import re +import tempfile +from time import time +from base64 import b64decode +import hashlib +import random +from time import sleep + +from module.plugins.Hoster import Hoster +from module.network.Request import getURL +from module.plugins.Plugin import chunks + + +def getInfo(urls): + api_url_base = "http://www.share-online.biz/linkcheck/linkcheck.php" + + for chunk in chunks(urls, 90): + api_param_file = {"links": "\n".join(x.replace("http://www.share-online.biz/dl/","") for x in chunk)} #api only supports old style links + src = getURL(api_url_base, post=api_param_file) + result = [] + for i, res in enumerate(src.split("\n")): + if not res: + continue + fields = res.split(";") + + if fields[1] == "OK": + status = 2 + elif fields[1] in ("DELETED", "NOT FOUND"): + status = 1 + else: + status = 3 + + result.append((fields[2], int(fields[3]), status, chunk[i])) + yield result + +class ShareonlineBiz(Hoster): + __name__ = "ShareonlineBiz" + __type__ = "hoster" + __pattern__ = r"(?:http://)?(?:www.)?share-online.biz/(download.php\?id=|dl/)" + __version__ = "0.2" + __description__ = """Shareonline.biz Download Hoster""" + __author_name__ = ("spoob", "mkaay") + __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de") + + def setup(self): + #self.req.canContinue = self.multiDL = True if self.account else False + # range request not working? + self.multiDL = True if self.account else False + + def process(self, pyfile): + self.convertURL() + self.downloadAPIData() + pyfile.name = self.api_data["filename"] + pyfile.sync() + + self.downloadHTML() + + self.download(self.getFileUrl(), cookies=True) + + def downloadAPIData(self): + api_url_base = "http://www.share-online.biz/linkcheck/linkcheck.php?md5=1" + api_param_file = {"links": self.pyfile.url.replace("http://www.share-online.biz/dl/","")} #api only supports old style links + src = self.load(api_url_base, cookies=False, post=api_param_file) + + fields = src.split(";") + self.api_data = {} + self.api_data["fileid"] = fields[0] + self.api_data["status"] = fields[1] + if not self.api_data["status"] == "OK": + self.offline() + self.api_data["filename"] = fields[2] + self.api_data["size"] = fields[3] # in bytes + self.api_data["checksum"] = fields[4].strip().lower().replace("\n\n", "") # md5 + + def downloadHTML(self): + self.html = self.load(self.pyfile.url, cookies=True) + + if not self.account: + html = self.load("%s/free/" % self.pyfile.url, post={"dl_free":"1"}, cookies=True) + if re.search(r"/failure/full/1", self.req.lastEffectiveURL): + self.setWait(120) + self.log.debug("%s: no free slots, waiting 120 seconds" % (self.__name__)) + self.wait() + self.retry() + captcha = self.decryptCaptcha("http://www.share-online.biz/captcha.php", get={"rand":"0.%s" % random.randint(10**15,10**16)}, cookies=True) + + self.log.debug("%s Captcha: %s" % (self.__name__, captcha)) + sleep(3) + + html = self.load(self.pyfile.url, post={"captchacode": captcha}, cookies=True) + if re.search(r"Der Download ist Ihnen zu langsam", html): + #m = re.search("var timeout='(\d+)';", self.html[1]) + #self.waitUntil = time() + int(m.group(1)) if m else 30 + return True + + self.retry() + else: + return True + + def convertURL(self): + self.pyfile.url = self.pyfile.url.replace("http://www.share-online.biz/download.php?id=", "http://www.share-online.biz/dl/") + + def getFileUrl(self): + """ returns the absolute downloadable filepath + """ + if self.account: + return b64decode(re.search('var dl="(.*?)"', self.html).group(1)) + file_url_pattern = 'loadfilelink\.decode\("([^"]+)' + return b64decode(re.search(file_url_pattern, self.html).group(1)) + + def checksum(self, local_file): + if self.api_data and self.api_data["checksum"]: + h = hashlib.md5() + f = open(local_file, "rb") + h.update(f.read()) + f.close() + hexd = h.hexdigest() + if hexd == self.api_data["checksum"]: + return (True, 0) + else: + return (False, 1) + else: + return (True, 5) diff --git a/core/module/plugins/hoster/ShragleCom.py b/core/module/plugins/hoster/ShragleCom.py new file mode 100644 index 000000000..e634607b0 --- /dev/null +++ b/core/module/plugins/hoster/ShragleCom.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +import time + +from module.plugins.Hoster import Hoster + +class ShragleCom(Hoster): + __name__ = "ShragleCom" + __type__ = "hoster" + __pattern__ = r"http://(?:www.)?shragle.com/files/" + __version__ = "0.1" + __description__ = """Shragle Download PLugin""" + __author_name__ = ("RaNaN") + __author_mail__ = ("RaNaN@pyload.org") + + def __init__(self, parent): + Hoster.__init__(self, parent) + self.parent = parent + self.html = None + self.multi_dl = False + + def set_parent_status(self): + """ sets all available Statusinfos about a File in self.parent.status + """ + if self.html == None: + self.download_html() + self.parent.status.filename = self.get_file_name() + self.parent.status.url = self.get_file_url() + self.parent.status.wait = self.wait_until() + + def download_html(self): + url = self.parent.url + self.html = self.load(url) + self.time_plus_wait = time.time() + 10 + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + + self.fileID = re.search(r"name=\"fileID\" value=\"([^\"]+)", self.html).group(1) + self.dlSession = re.search(r"name=\"dlSession\" value=\"([^\"]+)", self.html).group(1) + self.userID = "" + self.password = "" + self.lang = "de" + return "http://srv4.shragle.com/download.php" + + def get_file_name(self): + if self.html == None: + self.download_html() + + file_name_pattern = r"<\/div><h2>(.+)<\/h2" + return re.search(file_name_pattern, self.html).group(1) + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + + if re.search(r"html", self.html) == None: + return False + else: + return True + + def proceed(self, url, location): + self.download(url, location, {'fileID': self.fileID, 'dlSession': self.dlSession, 'userID': self.userID, 'password': self.password, 'lang': self.lang}) diff --git a/core/module/plugins/hoster/StorageTo.py b/core/module/plugins/hoster/StorageTo.py new file mode 100644 index 000000000..f0660b40d --- /dev/null +++ b/core/module/plugins/hoster/StorageTo.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import time + +from module.plugins.Hoster import Hoster + +class StorageTo(Hoster): + __name__ = "StorageTo" + __type__ = "hoster" + __pattern__ = r"http://(?:www)?\.storage\.to/get/.*" + __version__ = "0.2" + __description__ = """Storage.to Download Hoster""" + __author_name__ = ("mkaay") + + def setup(self): + self.wantReconnect = False + self.api_data = None + self.html = None + self.multiDL = False + + def process(self, pyfile): + self.pyfile = pyfile + self.prepare() + self.download( self.get_file_url() ) + + + + + def prepare(self): + pyfile = self.pyfile + + self.req.clear_cookies() + + self.wantReconnect = False + + if not self.file_exists(): + self.offline() + + pyfile.name = self.get_file_name() + + self.setWait( self.get_wait_time() ) + + while self.wantReconnect: + self.wait() + self.download_api_data() + self.setWait( self.get_wait_time() ) + + return True + + def download_html(self): + url = self.parent.url + self.html = self.load(url, cookies=True) + + def download_api_data(self): + url = self.parent.url + info_url = url.replace("/get/", "/getlink/") + src = self.load(info_url, cookies=True) + pattern = re.compile(r"'(\w+)' : (.*?)[,|\}]") + self.api_data = {} + for pair in pattern.findall(src): + self.api_data[pair[0]] = pair[1].strip("'") + print self.api_data + + def get_wait_time(self): + if not self.api_data: + self.download_api_data() + if self.api_data["state"] == "wait": + self.wantReconnect = True + else: + self.wantReconnect = False + + return int(self.api_data["countdown"]) + 3 + + + + def file_exists(self): + """ returns True or False + """ + if not self.api_data: + self.download_api_data() + if self.api_data["state"] == "failed": + return False + else: + return True + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if not self.api_data: + self.download_api_data() + return self.api_data["link"] + + def get_file_name(self): + if not self.html: + self.download_html() + file_name_pattern = r"<span class=\"orange\">Downloading:</span>(.*?)<span class=\"light\">(.*?)</span>" + return re.search(file_name_pattern, self.html).group(1).strip() diff --git a/core/module/plugins/hoster/UploadedTo.py b/core/module/plugins/hoster/UploadedTo.py new file mode 100644 index 000000000..b6bd872f1 --- /dev/null +++ b/core/module/plugins/hoster/UploadedTo.py @@ -0,0 +1,151 @@ +# -*- coding: utf-8 -*- + +import re +from time import time +from module.plugins.Hoster import Hoster +from module.network.Request import getURL +import hashlib + +def getInfo(urls): + for url in urls: + match = re.compile(UploadedTo.__pattern__).search(url) + if match: + src = getURL("http://uploaded.to/api/file", get={"id": match.group(1).split("/")[0]}) + if src.find("404 Not Found") >= 0: + result.append((url, 0, 1, url)) + continue + lines = src.splitlines() + result.append((lines[0], int(lines[1]), 2, url)) + +class UploadedTo(Hoster): + __name__ = "UploadedTo" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?u(?:p)?l(?:oaded)?\.to/(?:file/|\?id=)?(.+)" + __version__ = "0.4" + __description__ = """Uploaded.to Download Hoster""" + __author_name__ = ("spoob", "mkaay") + __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de") + + + def setup(self): + self.html = None + self.api_data = None + self.multiDL = False + if self.account: + self.multiDL = True + self.req.canContinue = True + + def process(self, pyfile): + self.url = False + self.pyfile = pyfile + self.prepare() + self.proceed() + + + def getInfo(self): + self.download_api_data() + self.pyfile.name = self.api_data["filename"] + self.pyfile.sync() + + def prepare(self): + tries = 0 + + while not self.url: + self.download_html() + + if not self.file_exists(): + self.offline() + + self.download_api_data() + + # self.pyfile.name = self.get_file_name() + + if self.account: + info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) + self.log.debug(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) + if self.api_data["size"]/1024 > info["trafficleft"]: + self.log.info(_("%s: Not enough traffic left" % self.__name__)) + self.resetAcount() + else: + self.url = self.get_file_url() + self.pyfile.name = self.get_file_name() + return True + + self.url = self.get_file_url() + + self.setWait(self.get_waiting_time()) + self.wait() + + self.pyfile.name = self.get_file_name() + + tries += 1 + if tries > 5: + self.fail("Error while preparing DL") + return True + + def download_api_data(self, force=False): + if self.api_data and not force: + return + match = re.compile(self.__pattern__).search(self.pyfile.url) + if match: + src = self.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]}) + if not src.find("404 Not Found"): + return + self.api_data = {} + lines = src.splitlines() + self.api_data["filename"] = lines[0] + self.api_data["size"] = int(lines[1]) # in bytes + self.api_data["checksum"] = lines[2] #sha1 + + def download_html(self): + self.html = self.load(self.pyfile.url, cookies=False) + + def get_waiting_time(self): + try: + wait_minutes = re.search(r"Or wait ([\d\-]+) minutes", self.html).group(1) + if int(wait_minutes) < 0: wait_minutes = 1 + self.wantReconnect = True + return 60 * int(wait_minutes) + except: + return 0 + + def get_file_url(self): + if self.account: + self.start_dl = True + return self.cleanUrl(self.pyfile.url) + try: + file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">" + return re.search(file_url_pattern, self.html).group(1) + except: + return None + + def get_file_name(self): + try: + if self.api_data and self.api_data["filename"]: + return self.api_data["filename"] + file_name = re.search(r"<td><b>\s+(.+)\s", self.html).group(1) + file_suffix = re.search(r"</td><td>(\..+)</td></tr>", self.html) + if not file_suffix: + return file_name + return file_name + file_suffix.group(1) + except: + return self.pyfile.url.split('/')[-1] + + def file_exists(self): + if re.search(r"(File doesn't exist)", self.html) != None: + return False + else: + return True + + def cleanUrl(self, url): + url = url.replace("ul.to/", "uploaded.to/file/") + url = url.replace("/?id=", "/file/") + url = url.replace("?id=", "file/") + url = re.sub("/\?(.*?)&id=", "/file/", url, 1) + return url + + def proceed(self): + if self.account: + self.download(self.url+"?redirect", cookies=True) + else: + self.download(self.url, cookies=False, post={"download_submit": "Free Download"}) diff --git a/core/module/plugins/hoster/Xdcc.py b/core/module/plugins/hoster/Xdcc.py new file mode 100644 index 000000000..52ece4ca4 --- /dev/null +++ b/core/module/plugins/hoster/Xdcc.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*-
+
+"""
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: jeix
+"""
+
+import logging
+from os.path import exists
+from os.path import join
+from os.path import exists
+from os import makedirs
+import re
+import sys
+
+from module.plugins.Hoster import Hoster
+
+
+class Xdcc(Hoster):
+ __name__ = "Xdcc"
+ __version__ = "0.2"
+ __pattern__ = r'xdcc://.*?(/#?.*?)?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/#channel/[XDCC]|Shit/#0004/
+ __type__ = "hoster"
+ __config__ = [
+ ("nick", "str", "Nickname", "pyload"),
+ ("ident", "str", "Ident", "pyloadident"),
+ ("realname", "str", "Realname", "pyloadreal")
+ ]
+ __description__ = """A Plugin that allows you to download from an IRC XDCC bot"""
+ __author_name__ = ("jeix")
+ __author_mail__ = ("jeix@hasnomail.com")
+
+ def process(self, pyfile):
+ self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC")
+ self.doDownload(pyfile.url)
+
+ def doDownload(self, url):
+ self.pyfile.setStatus("downloading")
+
+ download_folder = self.config['general']['download_folder']
+ location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
+ if not exists(location):
+ makedirs(location)
+
+ m = re.search(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url)
+ server = m.group(1)
+ chan = m.group(2)
+ bot = m.group(3)
+ pack = m.group(4)
+ nick = self.getConf('nick')
+ ident = self.getConf('ident')
+ real = self.getConf('realname')
+
+ newname = self.req.download(bot, pack, location, nick, ident, real, chan, server)
+ self.pyfile.size = self.req.dl_size
+
+ if newname:
+ self.pyfile.name = newname
+
\ No newline at end of file diff --git a/core/module/plugins/hoster/YoupornCom.py b/core/module/plugins/hoster/YoupornCom.py new file mode 100644 index 000000000..5c07f2c84 --- /dev/null +++ b/core/module/plugins/hoster/YoupornCom.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class YoupornCom(Hoster): + __name__ = "YoupornCom" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?youporn\.com/watch/.+" + __version__ = "0.1" + __description__ = """Youporn.com Video Download Hoster""" + __author_name__ = ("willnix") + __author_mail__ = ("willnix@pyload.org") + + def __init__(self, parent): + Hoster.__init__(self, parent) + self.parent = parent + self.html = None + self.html_old = None #time() where loaded the HTML + self.time_plus_wait = None #time() + wait in seconds + + def set_parent_status(self): + """ sets all available Statusinfos about a File in self.parent.status + """ + if self.html == None: + self.download_html() + self.parent.status.filename = self.get_file_name() + self.parent.status.url = self.get_file_url() + self.parent.status.wait = self.wait_until() + + def download_html(self): + url = self.parent.url + self.html = self.load(url, post={"user_choice":"Enter"}, cookies=False) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + + file_url = re.search(r'(http://download.youporn.com/download/\d*/.*\?download=1&ll=1&t=dd)">', self.html).group(1) + return file_url + + def get_file_name(self): + if self.html == None: + self.download_html() + + file_name_pattern = r".*<title>(.*) - Free Porn Videos - YouPorn.com Lite \(BETA\)</title>.*" + return re.search(file_name_pattern, self.html).group(1).replace("&", "&").replace("/","") + '.flv' + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + if re.search(r"(.*invalid video_id.*)", self.html) != None: + return False + else: + return True diff --git a/core/module/plugins/hoster/YoutubeCom.py b/core/module/plugins/hoster/YoutubeCom.py new file mode 100644 index 000000000..79c359ad7 --- /dev/null +++ b/core/module/plugins/hoster/YoutubeCom.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class YoutubeCom(Hoster): + __name__ = "YoutubeCom" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" + __version__ = "0.2" + __config__ = [ ("quality", "str" , "Quality Setting", "hd") ] + __description__ = """Youtube.com Video Download Hoster""" + __author_name__ = ("spoob") + __author_mail__ = ("spoob@pyload.org") + + def process(self, pyfile): + html = self.load(pyfile.url) + + if re.search(r"(.*eine fehlerhafte Video-ID\.)", html) != None: + self.offline() + + videoId = pyfile.url.split("v=")[1].split("&")[0] + videoHash = re.search(r'&t=(.+?)&', html).group(1) + + + file_name_pattern = '<meta name="title" content="(.+?)">' + is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)" + file_suffix = ".flv" + is_hd = re.search(is_hd_pattern, html).group(1) + hd_available = (is_hd == "true") + + if self.getConf("quality") == "hd" or self.getConf("quality") == "hq": + file_suffix = ".mp4" + + name = (re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix).decode("utf8") + pyfile.name = name #.replace("&", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue") + + if self.getConf("quality") == "sd": + quality = "&fmt=6" + elif self.getConf("quality") == "hd" and hd_available: + quality = "&fmt=22" + else: + quality = "&fmt=18" + + file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality + "&asv=2" + + self.download(file_url) diff --git a/core/module/plugins/hoster/ZippyshareCom.py b/core/module/plugins/hoster/ZippyshareCom.py new file mode 100644 index 000000000..3740f8c14 --- /dev/null +++ b/core/module/plugins/hoster/ZippyshareCom.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +import urllib +from module.plugins.Hoster import Hoster + +class ZippyshareCom(Hoster): + __name__ = "ZippyshareCom" + __type__ = "hoster" + __pattern__ = r"(http://)?www?\d{0,2}\.zippyshare.com/v/" + __version__ = "0.2" + __description__ = """Zippyshare.com Download Hoster""" + __author_name__ = ("spoob") + __author_mail__ = ("spoob@pyload.org") + + def setup(self): + self.html = None + self.wantReconnect = False + self.multiDL = False + + def process(self, pyfile): + self.pyfile = pyfile + self.download_html() + if not self.file_exists(): + self.offline() + + pyfile.name = self.get_file_name() + self.download(self.get_file_url()) + + def download_html(self): + url = self.pyfile.url + self.html = self.load(url, cookies=True) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + file_url_pattern = r"var \w* = '(http%.*?)';" + file_url_search = re.search(file_url_pattern, self.html).group(1) + file_url = urllib.unquote(file_url_search.replace("nnn", "aaa").replace("unlg", "v").replace("serwus", "zippyshare")) + return file_url + + def get_file_name(self): + if self.html == None: + self.download_html() + if not self.wantReconnect: + file_name = re.search(r'Name: </font> <font.*>(.*?)</font>', self.html).group(1) + return file_name + else: + return self.pyfile.url + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + if re.search(r'File does not exist on this server', self.html) != None: + return False + else: + return True diff --git a/core/module/plugins/hoster/__init__.py b/core/module/plugins/hoster/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/core/module/plugins/hoster/__init__.py |