From 07471fe730b0a50fb3b23ec0eb78061046867500 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 30 Apr 2011 21:37:01 +0200 Subject: closed #294, #295 --- module/plugins/hoster/BasePlugin.py | 6 +-- module/plugins/hoster/FilesonicCom.py | 89 +++++++++++++++++++++++++++-------- module/plugins/hoster/UploadedTo.py | 13 ++++- 3 files changed, 81 insertions(+), 27 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 50652010c..7b3f56c4d 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -31,14 +31,10 @@ class BasePlugin(Hoster): # self.core.server_methods.add_package("test", [str(i) for i in range(80)], 1) # # return - - - self.load("http://pyload.org", just_header=True) - if pyfile.url.startswith("http"): pyfile.name = re.findall("([^/=]+)", pyfile.url)[-1] - self.download(pyfile.url) + self.download(pyfile.url, disposition=True) else: self.fail("No Plugin matched and not a downloadable url.") \ No newline at end of file diff --git a/module/plugins/hoster/FilesonicCom.py b/module/plugins/hoster/FilesonicCom.py index ce441f482..c3e3febb8 100644 --- a/module/plugins/hoster/FilesonicCom.py +++ b/module/plugins/hoster/FilesonicCom.py @@ -8,24 +8,36 @@ from module.plugins.ReCaptcha import ReCaptcha from module.plugins.Plugin import chunks from module.network.RequestFactory import getURL +from module.utils import decode + def getInfo(urls): for chunk in chunks(urls, 15): - page = getURL("http://www.filesonic.com/link-checker", post={"links": "\n".join(chunk)}).decode("utf8", "ignore") - - found = re.findall(r'\s+([^<]+)\s+([^<]+)\s+([0-9]+) MB\s+\s+([^<]+)
\s+
\s+\s+', page, re.MULTILINE) + # Always use "filesonic.com" for file's url + # mod_link contains the right url to check + orig_link = "".join(chunk) + mod_link = orig_link + url_datas = re.search("(.+)(filesonic\..+)/file/(.+)", orig_link) + if url_datas: + mod_link = url_datas.group(1) + "filesonic.com" + "/file/" + url_datas.group(3) + + page = getURL("http://www." + getDomain() + "/link-checker", post={"links": mod_link}).decode("utf8", "ignore") + + found = re.findall(r'\s+([^<]+)\s+([^<]+)\s+(.+) MB\s+\s+([^<]+)
\s+
\s+\s+', page, re.MULTILINE) result = [] for src, name, size, status in found: - result.append((name, int(size)*1024*1024, 2 if status == "Available" else 1, src)) - - + result.append((name, float(size)*1024*1024, 2 if status == "Available" else 1, src)) yield result - + +def getDomain(): + html = decode(getURL("http://api.filesonic.com/utility?method=getFilesonicDomainForCurrentIp")) + return re.search(r"response>.*?filesonic(\..*?)Download (.*?) for free on Filesonic.com', self.html) if name: @@ -54,13 +65,13 @@ class FilesonicCom(Hoster): self.download(self.getFileUrl()) def getFileUrl(self): - - link = self.url + "/" + re.search(r'href="(.*?start=1.*?)"', self.html).group(1) + part_1_link = re.search("(.+/file/\d+/)", self.url).group(1) + link = part_1_link + re.search(r'href="(.*?start=1.*?)"', self.html).group(1) self.html = self.load(link) self.handleErrors() - realLinkRegexp = "

Start download now!

" + realLinkRegexp = "

Start download now!

" url = re.search(realLinkRegexp, self.html) if not url: @@ -78,17 +89,42 @@ class FilesonicCom(Hoster): self.log.info("%s: Waiting %d seconds." % (self.__name__, wait_time)) self.wait() - tm = re.search("name='tm' value='(.*?)' />", self.html).group(1) - tm_hash = re.search("name='tm_hash' value='(.*?)' />", self.html).group(1) + tm = re.search("name='tm' value='(.*?)' />", self.html) + tm_hash = re.search("name='tm_hash' value='(.*?)' />", self.html) + + if tm and tm_hash: + tm = tm.group(1) + tm_hash = tm_hash.group(1) + else: + self.html = self.load(link) + self.handleErrors() + url = re.search(realLinkRegexp, self.html) + if not url: + if "This file is available for premium users only." in self.html: + self.fail("Need premium account.") + + countDownDelay = re.search("countDownDelay = (\\d+)", self.html) + if countDownDelay: + wait_time = int(countDownDelay.group(1)) + + if wait_time > 300: + self.wantReconnect = True - self.html = self.load(self.url + "?start=1", post={"tm":tm,"tm_hash":tm_hash}) + self.setWait(wait_time) + self.log.info("%s: Waiting %d seconds." % (self.__name__, wait_time)) + self.wait() + + tm = re.search("name='tm' value='(.*?)' />", self.html).group(1) + tm_hash = re.search("name='tm_hash' value='(.*?)' />", self.html).group(1) + self.html = self.load(self.url + "?start=1", post={"tm":tm,"tm_hash":tm_hash}) + self.handleErrors() if "Please Enter Password" in self.html: self.fail("implement need pw") - + chall = re.search(r'Recaptcha.create\("(.*?)",', self.html) for i in range(5): if not chall: break @@ -104,15 +140,22 @@ class FilesonicCom(Hoster): if chall: self.invalidCaptcha() - - url = re.search(realLinkRegexp, self.html).group(1) + + re_url = re.search(realLinkRegexp, self.html) + if re_url: + url = re_url.group(1) + + if not url: + self.fail("Plugin failed") + return url def convertURL(self, url): id = re.search("/file/([0-9]+(/.+)?)", url) if not id: id = re.search("/file/[a-z0-9]+/([0-9]+(/.+)?)", url) - return "http://www.filesonic.com/file/" + id.group(1) + result = "http://www.filesonic.com/file/" + id.group(1) + return self.getRightUrl(result) def handleErrors(self): if "The file that you're trying to download is larger than" in self.html: @@ -135,3 +178,9 @@ class FilesonicCom(Hoster): if "This file was deleted" in self.html: self.offline() + + def getRightUrl(self, url): + part_2 = re.search("http://www..+(/file.+)", url) + if not part_2: + part_2 = re.search("http://.+(/file.+)", url) + return "http://www.%s%s" % (getDomain(), part_2.group(1)) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index a593e9355..18d886947 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -145,17 +145,26 @@ class UploadedTo(Hoster): result = self.load(url, post=options) self.log.debug("UploadedTo result: %s" % result) - if "limit-dl" in result: + if "limit-size" in result: + self.fail("File too big for free download") + elif "limit-slot" in result: # Temporary restriction so just wait a bit + self.setWait(30 * 60, True) + self.wait() + self.retry() + elif "limit-parallel" in result: + self.fail("Cannot download in parallel") + elif "limit-dl" in result: self.setWait(30 * 60, True) self.wait() self.retry() elif 'err:"captcha"' in result: self.invalidCaptcha() elif "type:'download'" in result: + self.correctCaptcha() downloadURL = re.search("url:'([^']+)", result).group(1) break if not downloadURL: - self.fail("No Download url retrieved") + self.fail("No Download url retrieved/all captcha attempts failed") self.download(downloadURL) -- cgit v1.2.3