From 8d3d5625aa14614f5799621137a27f07d08e3dca Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Tue, 29 Nov 2011 21:45:27 +0100 Subject: update hellspy.cz, add bayfiles.com --- module/plugins/hoster/BayfilesCom.py | 77 +++++++++++++++++++++++++++++++ module/plugins/hoster/CzshareCom.py | 4 +- module/plugins/hoster/EnteruploadCom.py | 81 +++++++++++++++++++++++++++++++++ module/plugins/hoster/HellspyCz.py | 74 +++++++++--------------------- 4 files changed, 182 insertions(+), 54 deletions(-) create mode 100644 module/plugins/hoster/BayfilesCom.py create mode 100644 module/plugins/hoster/EnteruploadCom.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py new file mode 100644 index 000000000..c771f28c6 --- /dev/null +++ b/module/plugins/hoster/BayfilesCom.py @@ -0,0 +1,77 @@ +# -*- 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 . + + @author: zoidberg +""" + +import re +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.ReCaptcha import ReCaptcha +from module.common.json_layer import json_loads +from time import time + +class BayfilesCom(SimpleHoster): + __name__ = "BayfilesCom" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?bayfiles\.com/file/\w+/\w+/.*" + __version__ = "0.01" + __description__ = """Bayfiles.com plugin - free only""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_INFO_PATTERN = r'

[^<]*(?P[0-9., ]+)(?P[kKMG])i?B

' + FILE_OFFLINE_PATTERN = r'

The requested file could not be found.

' + + WAIT_PATTERN = r'>Your IP [0-9.]* has recently downloaded a file\. Upgrade to premium or wait (\d+) minutes\.<' + VARS_PATTERN = r'var vfid = (\d+);\s*var delay = (\d+);' + LINK_PATTERN = r"javascript:window.location.href = '([^']+)';" + + def handleFree(self): + found = re.search(self.WAIT_PATTERN, self.html) + if found: + self.setWait(int(found.group(1)) * 60) + self.wait() + self.retry() + + # Get download token + found = re.search(self.VARS_PATTERN, self.html) + if not found: self.parseError('VARS') + vfid, delay = found.groups() + + response = json_loads(self.load('http://bayfiles.com/ajax_download', get = { + "_": time() * 1000, + "action": "startTimer", + "vfid": vfid}, decode = True)) + + if not "token" in response or not response['token']: + self.fail('No token') + + self.setWait(int(delay)) + self.wait() + + self.html = self.load('http://bayfiles.com/ajax_download', get = { + "token": response['token'], + "action": "getLink", + "vfid": vfid}) + + # Get final link and download + found = re.search(self.LINK_PATTERN, self.html) + if not found: self.parseError("Free link") + url = found.group(1) + self.logDebug("URL: " + url) + + self.download(url) + +getInfo = create_getInfo(BayfilesCom) \ No newline at end of file diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 1a705e302..158fb0d1d 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -45,11 +45,11 @@ class CzshareCom(SimpleHoster): __name__ = "CzshareCom" __type__ = "hoster" __pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/(\d+/|download.php\?).*" - __version__ = "0.84" + __version__ = "0.85" __description__ = """CZshare.com""" __author_name__ = ("zoidberg") - SIZE_REPLACEMENTS = {',': '.', ' ': ''} + SIZE_REPLACEMENTS = [(',', '.'), (' ', '')] FREE_URL_PATTERN = r'[^>]*alt="([^"]+)" />' FREE_FORM_PATTERN = r'
\s*(.*?)
' PREMIUM_FORM_PATTERN = r'
(.*?)
' diff --git a/module/plugins/hoster/EnteruploadCom.py b/module/plugins/hoster/EnteruploadCom.py new file mode 100644 index 000000000..5e899ae96 --- /dev/null +++ b/module/plugins/hoster/EnteruploadCom.py @@ -0,0 +1,81 @@ +# -*- 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 . + + @author: zoidberg +""" + +import re +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + +class EnteruploadCom(SimpleHoster): + __name__ = "EnteruploadCom" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?enterupload.com/\w+.*" + __version__ = "0.01" + __description__ = """EnterUpload.com plugin - free only""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_INFO_PATTERN = r'

(?P[^<]+)

\s*File size:\s*(?P[0-9.]+)\s*(?P[kKMG])i?B' + FILE_OFFLINE_PATTERN = r'<(b|h2)>File Not Found|No such file with this filename' + URL_REPLACEMENTS = [(r"(http://(?:www\.)?enterupload.com/\w+).*", r"\1")] + + FORM1_PATTERN = r'
(.*?)
' + FORM2_PATTERN = r'
]*>(.*?)
' + FORM3_PATTERN = r'
' + FORM_INPUT_PATTERN = r']* name="([^"]+)" value="([^"]*)"[^>]*>' + WAIT_PATTERN = r'Wait <[^>]*>(\d+) seconds' + + def handleFree(self): + # Page 1 + try: + form = re.search(self.FORM1_PATTERN, self.html, re.DOTALL).group(1) + inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) + except Exception, e: + self.logError(e) + self.parseError("Form 1") + + inputs['method_free'] = 'Free Download' + self.logDebug(inputs) + self.html = self.load(self.pyfile.url, post = inputs, decode = True, cookies = True, ref = True) + + # Page 2 + try: + form = re.search(self.FORM2_PATTERN, self.html, re.DOTALL).group(1) + inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) + except Exception, e: + self.logError(e) + self.parseError("Form 2") + + inputs['method_free'] = self.pyfile.url + self.logDebug(inputs) + + found = re.search(self.WAIT_PATTERN, self.html) + if found: + self.setWait(int(found.group(1)) + 1) + self.wait() + + self.html = self.load(self.pyfile.url, post = inputs, decode = True, cookies = True, ref = True) + + # Page 3 + found = re.search(self.FORM3_PATTERN, self.html) + if not found: self.parseError("Form 3") + url = found.group(1) + + # Download + self.logDebug("Download URL: " + url) + self.download(url, cookies = True, ref = True) + +getInfo = create_getInfo(EnteruploadCom) \ No newline at end of file diff --git a/module/plugins/hoster/HellspyCz.py b/module/plugins/hoster/HellspyCz.py index 6d3f84b55..9a8817c54 100644 --- a/module/plugins/hoster/HellspyCz.py +++ b/module/plugins/hoster/HellspyCz.py @@ -17,83 +17,53 @@ """ import re -from math import ceil -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo -from module.network.RequestFactory import getURL - -def getInfo(urls): - result = [] - - for url in urls: - file_info = parseFileInfo(HellspyCz, url, getURL(url, decode=True)) - result.append(file_info) - - yield result +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class HellspyCz(SimpleHoster): __name__ = "HellspyCz" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)*hellspy\.(?:cz|com|sk|hu)(/\S+/\d+)/?.*" - __version__ = "0.22" + __version__ = "0.23" __description__ = """HellSpy.cz""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") FILE_INFO_PATTERN = '(?P[0-9.]+) (?P[kKMG])i?B\s*

(?P[^<]+)

' FILE_OFFLINE_PATTERN = r'

(404 - Page|File) not found

' + URL_REPLACEMENTS = [(r"http://(?:\w*\.)*hellspy\.(?:cz|com|sk|hu)(/\S+/\d+)/?.*", r"http://www.hellspy.com\1")] + CREDIT_LEFT_PATTERN = r'Credits: \s*(\d+)' - PREMIUM_URL_PATTERN = r']*title="You can download the file without deducting your credit.">' + DOWNLOAD_URL_PATTERN = r"launchFullDownload\('([^']+)'" def setup(self): - self.resumeDownload = self.multiDL = True if self.account else False + self.resumeDownload = self.multiDL = True self.chunkLimit = 1 - def process(self, pyfile): - if not self.account: self.fail("Only premium users can download from HellSpy.cz") + def handleFree(self): + self.fail("Only premium users can download from HellSpy.cz") + def handlePremium(self): # set PHPSESSID cookie cj = self.account.getAccountCookies(self.user) cj.setCookie(".hellspy.com", "PHPSESSID", self.account.phpsessid) self.logDebug("PHPSESSID: " + cj.getCookie("PHPSESSID")) - info = self.account.getAccountInfo(self.user) + info = self.account.getAccountInfo(self.user, True) self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"]/1024)) - # load html - rel_url = re.search(self.__pattern__, pyfile.url).group(1) - self.html = self.load("http://www.hellspy.com/--%s-/%s" % (self.account.phpsessid, rel_url), decode = True) - - self.getFileInfo() + if self.pyfile.size / 1024 > info["trafficleft"]: + self.logWarning("Not enough credit left to download file") # get premium download URL and download - found = re.search(self.PREMIUM_URL_PATTERN, self.html) - if not found: self.parseError('Download URL') - download_url = "http://www.hellspy.cz" + found.group(1) - self.logDebug("Download URL: " + download_url) - self.download(download_url, disposition = True) - - info = self.account.getAccountInfo(self.user) + self.html = self.load(self.pyfile.url + "?download=1") + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + if not found: self.parseError("Download URL") + url = found.group(1) + self.logDebug("Download URL: " + url) + self.download(url) + + info = self.account.getAccountInfo(self.user, True) self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"]/1024)) - - """ - # parse credits left info - found = re.search(self.CREDIT_LEFT_PATTERN, self.html) - if found is None: - self.logInfo("Not logged in... relogin and retry") - self.account.relogin(self.user) - self.retry(max_tries = 2, reason = "Not logged in") - credits_left = int(found.group(1)) - self.logInfo("User %s has %i credits left" % (self.user, credits_left)) - - # parse credit needed to proceed - found = re.search(self.DOWNLOAD_AGAIN_PATTERN, self.html) - if found: - self.logInfo("Free download (file downloaded before)") - else: - found = re.search(self.FILE_CREDITS_PATTERN, self.html) - if found is None: self.fail("Parse error (FILE CREDITS)") - file_credits = int(found.group(3)) - if file_credits > credits_left: self.fail("Not enough credits left to download file") - self.logInfo("Premium download for %i credits" % file_credits) - """ + +getInfo = create_getInfo(HellspyCz) \ No newline at end of file -- cgit v1.2.3