From 9c33d5cd2f715bb7ae7d5a935f8ec0b22d991004 Mon Sep 17 00:00:00 2001 From: Paul King Date: Sat, 4 Jun 2011 21:18:24 +0100 Subject: tidy, fix getInfo --- module/plugins/hoster/X7To.py | 115 ++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 61 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/X7To.py b/module/plugins/hoster/X7To.py index 39441d091..5bf1403b8 100644 --- a/module/plugins/hoster/X7To.py +++ b/module/plugins/hoster/X7To.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import with_statement - import re from module.plugins.Hoster import Hoster @@ -11,31 +9,23 @@ def getInfo(urls): result = [] for url in urls: - #print "X7To: getinfo for "+url - # Get html html = getURL(url) - if re.search(r"var page = '404';", html): - #print "x7html: 404" + if "var page = '404';" in html: result.append((url, 0, 1, url)) continue - # Name - fileInfo = re.search(' size: @@ -94,51 +83,55 @@ class X7To(Hoster): # check if over limit first overLimit = re.search(r'', self.html) if overLimit: - self.logDebug("over limit") + self.logDebug("over limit, falling back to free") + self.handleFree() else: - realurl = re.search(r'', self.html) + realurl = re.search(r'', self.html) if realurl: - realurl = 'http://stor' + realurl.group(1) + '.x7.to/dl/' + realurl.group(2) + realurl = realurl.group(1) + self.logDebug("premium url found %s" % realurl) else: self.logDebug("premium link not found") self.download(realurl) def handleFree(self): # find file id - file_id = re.search(r"var dlID = '([^']*)'", self.html) - if file_id: - file_url = "http://x7.to/james/ticket/dl/" + file_id.group(1) - #getDownloadXml = getURL(file_url) - self.html = self.load(file_url, ref=False, decode=True) - - # find download limit in xml - haveToWait = re.search("limit-dl", self.html) - if haveToWait: - self.logDebug("Limit reached ... waiting") - self.setWait(900) - self.wait() - return True - - # no waiting required, go to download - waitCheck = re.search(r"wait:(\d*),", self.html) - if waitCheck: - waitCheck = int(waitCheck.group(1)) - self.setWait(waitCheck, True) - self.wait() - - urlCheck = re.search(r"url:'(.*)',", self.html) - url = None - if urlCheck: - url = urlCheck.group(1) - self.logDebug("url found " + url) - - if url: - try: - self.download(url) - except: - self.logDebug("downloading url failed:" + url) - - - else: - #print self.html - self.fail("no download url found") \ No newline at end of file + file_id = re.search(r"var dlID = '(.*?)'", self.html) + if not file_id: + self.fail("Free download id not found") + + file_url = "http://x7.to/james/ticket/dl/" + file_id.group(1) + self.logDebug("download id %s" % file_id.group(1)) + + self.html = self.load(file_url, ref=False, decode=True) + + # deal with errors + if "limit-dl" in self.html: + self.logDebug("Limit reached ... waiting") + self.setWait(900,True) + self.wait() + self.retry() + + if "limit-parallel" in self.html: + self.fail("Cannot download in parallel") + + # no waiting required, go to download + waitCheck = re.search(r"wait:(\d*),", self.html) + if waitCheck: + waitCheck = int(waitCheck.group(1)) + self.setWait(waitCheck) + self.wait() + + urlCheck = re.search(r"url:'(.*?)'", self.html) + url = None + if urlCheck: + url = urlCheck.group(1) + self.logDebug("free url found %s" % url) + + if url: + try: + self.download(url) + except: + self.logDebug("downloading url failed: %s" % url) + else: + self.fail("Free download url found") \ No newline at end of file -- cgit v1.2.3