summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/UploadboxCom.py
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-23 15:28:44 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-23 15:28:44 +0100
commit02c58f1009cc7f6b7ee36f1a34e43bec02735f05 (patch)
tree10fa0f86b54119769912ae2bc52775c0342d0f5f /module/plugins/hoster/UploadboxCom.py
parentfix 4shared, replace easy-share with crocko (diff)
downloadpyload-02c58f1009cc7f6b7ee36f1a34e43bec02735f05.tar.xz
add uploadbox.com, fshare.vn
Diffstat (limited to 'module/plugins/hoster/UploadboxCom.py')
-rw-r--r--module/plugins/hoster/UploadboxCom.py89
1 files changed, 89 insertions, 0 deletions
diff --git a/module/plugins/hoster/UploadboxCom.py b/module/plugins/hoster/UploadboxCom.py
new file mode 100644
index 000000000..04b4ac6aa
--- /dev/null
+++ b/module/plugins/hoster/UploadboxCom.py
@@ -0,0 +1,89 @@
+# -*- 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: zoidberg
+"""
+
+import re
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
+from module.network.RequestFactory import getURL
+
+def getInfo(urls):
+ for url in urls:
+ file_id = re.search(UploadboxCom.__pattern__, url).group(1)
+ html = unicode(getURL('http://uploadbox.com/files/%s/?ac=lang&lang_new=en' % file_id), 'cp1251')
+ file_info = parseFileInfo(UploadboxCom, url, html)
+ yield file_info
+
+class UploadboxCom(SimpleHoster):
+ __name__ = "Uploadbox"
+ __type__ = "hoster"
+ __pattern__ = r"http://(?:www\.)?uploadbox\.com/files/([^/]+).*"
+ __version__ = "0.02"
+ __description__ = """UploadBox.com plugin - free only"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FILE_NAME_PATTERN = r'<p><span>File name:</span>\s*(?P<N>[^<]+)</p>'
+ FILE_SIZE_PATTERN = r'<span>Size:</span>\s*(?P<S>[0-9.]+) (?P<U>[kKMG])i?B <span>'
+ FILE_OFFLINE_PATTERN = r'<strong>File deleted from service</strong>'
+
+ FREE_FORM_PATTERN = r'<form action="([^"]+)" method="post" id="free" name="free">(.*?)</form>'
+ FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)" />'
+ LIMIT_EXCEEDED_PATTERN = r'<strong>The limit of traffic for you is exceeded. Please </strong> <br />wait <strong>(\d+)</strong> minutes'
+ DOWNLOAD_URL_PATTERN = r'<iframe id="file_download"[^>]*src="([^"]+)"></iframe>'
+
+ def process(self, pyfile):
+ self.file_id = re.search(self.__pattern__, pyfile.url).group(1)
+ self.html = unicode(self.load('http://uploadbox.com/files/%s/?ac=lang&lang_new=en' % self.file_id), 'cp1251')
+ self.getFileInfo()
+ self.handleFree()
+
+ def handleFree(self):
+ # Solve captcha
+ url = 'http://uploadbox.com/files/' + self.file_id
+
+ for i in range(5):
+ self.html = self.load(url, post = {"free": "yes"})
+ found = re.search(self.LIMIT_EXCEEDED_PATTERN, self.html)
+ if found:
+ self.setWait(int(found.group(1))*60, True)
+ self.wait()
+ else:
+ break
+ else:
+ self.fail("Unable to get free download slot")
+
+ for i in range(5):
+ try:
+ action, form = re.search(self.FREE_FORM_PATTERN, self.html, re.DOTALL).groups()
+ inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))
+ except Exception, e:
+ self.logError(e)
+ self.fail("Parse error on page 2")
+
+ captcha_url = 'http://uploadbox.com/?ac=captcha&code=' + inputs['code']
+ inputs['enter'] = self.decryptCaptcha(captcha_url)
+ self.html = self.load('http://uploadbox.com/' + action, post = inputs)
+ found = re.search(self.DOWNLOAD_URL_PATTERN, self.html)
+ if found:
+ self.correctCaptcha()
+ download_url = found.group(1)
+ break
+ else:
+ self.fail("Incorrect captcha entered 5 times")
+
+ # Download
+ self.download(download_url) \ No newline at end of file