summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/FilefactoryCom.py
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-05-21 00:48:34 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-05-21 00:48:34 +0200
commit66546318cd9faf655318ff56722294565fa8397a (patch)
tree847a3862a92df8d0f3180e8cd8f8f640ef0a43c9 /module/plugins/hoster/FilefactoryCom.py
parentclosed #602, #588 (diff)
downloadpyload-66546318cd9faf655318ff56722294565fa8397a.tar.xz
update filefactory, add datei.to, jumbofiles.com
Diffstat (limited to 'module/plugins/hoster/FilefactoryCom.py')
-rw-r--r--module/plugins/hoster/FilefactoryCom.py68
1 files changed, 29 insertions, 39 deletions
diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py
index 4f6666675..135dd90a1 100644
--- a/module/plugins/hoster/FilefactoryCom.py
+++ b/module/plugins/hoster/FilefactoryCom.py
@@ -4,6 +4,7 @@ from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
from module.utils import parseFileSize
from module.plugins.Plugin import chunks
+from module.common.json_layer import json_loads
import re
@@ -16,7 +17,7 @@ def checkFile(plugin, urls):
url_ids = url_dict.keys()
urls = map(lambda url_id: 'http://www.filefactory.com/file/' + url_id, url_ids)
- html = getURL("http://filefactory.com/tool/links.php", post = {"func": "links", "links": "\n".join(urls)}, decode=True)
+ html = getURL("http://www.filefactory.com/tool/links.php", post = {"func": "links", "links": "\n".join(urls)}, decode=True)
for m in re.finditer(plugin.LC_INFO_PATTERN, html):
if m.group('id') in url_ids:
@@ -34,29 +35,28 @@ class FilefactoryCom(Hoster):
__name__ = "FilefactoryCom"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+).*" # URLs given out are often longer but this is the requirement
- __version__ = "0.33"
+ __version__ = "0.34"
__description__ = """Filefactory.Com File Download Hoster"""
__author_name__ = ("paulking", "zoidberg")
- LC_INFO_PATTERN = r'<tr class="(even|odd)">\s*<td>\s*<a href="http://www.filefactory.com/file/(?P<id>\w+)[^"]*">(?P<name>[^<]+)</a>\s*.*\s*</td>\s*<td>(?P<size>[0-9.]+ \w+)</td>'
- LC_OFFLINE_PATTERN = r'<li class="(even|odd)">\s*<div class="metadata">http://www.filefactory.com/file/(?P<id>\w+)/</div>'
-
+ LC_INFO_PATTERN = r'<h1 class="name">(?P<name>[^<]+) \((?P<size>[0-9.]+ \w+)\)</h1>\s*<p>http://www.filefactory.com/file/(?P<id>\w+)/'
+ LC_OFFLINE_PATTERN = r'<p>http://www.filefactory.com/file/(?P<id>\w+)/</p>\s*<p class="errorResponse">'
+
FILE_OFFLINE_PATTERN = r'<title>File Not Found'
FILE_NAME_PATTERN = r'<span class="last">(?P<name>.*?)</span>'
FILE_INFO_PATTERN = r'<span>(?P<size>\d(\d|\.)*) (?P<units>..) file uploaded'
- FILE_CHECK_PATTERN = r'check:\'(?P<check>.*?)\''
- CAPTCHA_KEY_PATTERN = r'Recaptcha.create\("(?P<recaptchakey>.*?)",'
- WAIT_PATH_PATTERN = r'path:"(?P<path>.*?)"'
+ FILE_CHECK_PATTERN = r'check:\s*\'(?P<check>.*?)\''
+ CAPTCHA_KEY_PATTERN = r'Recaptcha.create\(\s*"(.*?)",'
WAIT_PATTERN = r'id="startWait" value="(?P<wait>\d+)"'
- FILE_URL_PATTERN = r'<a href="(?P<url>.*?)" id="downloadLinkTarget">'
+ FILE_URL_PATTERN = r'<p[^>]*?id="downloadLinkTarget"[^>]*>\s*<a href="(?P<url>.*?)"'
def setup(self):
self.multiDL = self.resumeDownloads = self.premium
def process(self, pyfile):
# Check file
- pyfile.name, pyfile.size, status, self.url = checkFile(self, [pyfile.url])[0]
+ pyfile.name, pyfile.size, status, self.url = checkFile(self, [pyfile.url])[0]
if status != 2: self.offline()
self.logDebug("File Name: %s Size: %d" % (pyfile.name, pyfile.size))
@@ -93,42 +93,41 @@ class FilefactoryCom(Hoster):
# Check Id
self.check = re.search(self.FILE_CHECK_PATTERN, self.html).group('check')
- self.log.debug("%s: File check code is [%s]" % (self.__name__, self.check))
+ self.logDebug("File check code is [%s]" % self.check)
# Resolve captcha
- self.log.debug("%s: File is captcha protected" % self.__name__)
- id = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group('recaptchakey')
+ found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
+ recaptcha_key = found.group(1) if found else "6LeN8roSAAAAAPdC1zy399Qei4b1BwmSBSsBN8zm"
+ recaptcha = ReCaptcha(self)
+
# Try up to 5 times
- for i in range(5):
- self.log.debug("%s: Resolving ReCaptcha with key [%s], round %d" % (self.__name__, id, i+1))
- recaptcha = ReCaptcha(self)
- challenge, code = recaptcha.challenge(id)
- response = self.load("http://www.filefactory.com/file/checkCaptcha.php",
- post={"check" : self.check, "recaptcha_challenge_field" : challenge, "recaptcha_response_field" : code})
- captchavalid = self.handleCaptchaErrors(response)
- if captchavalid:
+ for i in range(5):
+ challenge, code = recaptcha.challenge(recaptcha_key)
+ response = json_loads(self.load("http://www.filefactory.com/file/checkCaptcha.php",
+ post={"check" : self.check, "recaptcha_challenge_field" : challenge, "recaptcha_response_field" : code}))
+ if response['status'] == 'ok':
+ self.correctCaptcha()
break
- if not captchavalid:
+ else:
+ self.invalidCaptcha()
+ else:
self.fail("No valid captcha after 5 attempts")
-
- # Get wait URL
- waitpath = re.search(self.WAIT_PATH_PATTERN, response).group('path')
- waiturl = "http://www.filefactory.com" + waitpath
# This will take us to a wait screen
- self.log.debug("%s: fetching wait with url [%s]" % (self.__name__, waiturl))
+ waiturl = "http://www.filefactory.com" + response['path']
+ self.logDebug("Fetching wait with url [%s]" % waiturl)
waithtml = self.load(waiturl, decode=True)
# Find the wait value and wait
wait = int(re.search(self.WAIT_PATTERN, waithtml).group('wait'))
- self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait))
+ self.logDebug("Waiting %d seconds." % wait)
self.setWait(wait, True)
self.wait()
# Now get the real download url and retrieve the file
url = re.search(self.FILE_URL_PATTERN,waithtml).group('url')
# this may either download our file or forward us to an error page
- self.log.debug("%s: download url %s" % (self.__name__, url))
+ self.logDebug("Download URL: %s" % url)
dl = self.download(url)
check = self.checkDownload({"multiple": "You are currently downloading too many files at once.",
@@ -136,20 +135,11 @@ class FilefactoryCom(Hoster):
if check == "multiple":
self.setWait(15*60)
- self.log.debug("%s: Parallel downloads detected waiting 15 minutes" % self.__name__)
+ self.logDebug("Parallel downloads detected; waiting 15 minutes")
self.wait()
self.retry()
elif check == "error":
self.fail("Unknown error")
-
- def handleCaptchaErrors(self, response):
- self.log.debug("%s: Result of captcha resolving [%s]" % (self.__name__, response))
- if 'status:"ok"' in response:
- self.correctCaptcha()
- return True
-
- self.log.debug("%s: Wrong captcha" % self.__name__)
- self.invalidCaptcha()
def handlePremium(self):
self.fail('Please enable direct downloads')