From 3c7b7eaa189dd030712290fea2b2655b69fd6c05 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 4 Jun 2011 17:22:51 +0200 Subject: x7.to plugin, by ernieb --- module/plugins/hoster/X7To.py | 144 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 module/plugins/hoster/X7To.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/X7To.py b/module/plugins/hoster/X7To.py new file mode 100644 index 000000000..39441d091 --- /dev/null +++ b/module/plugins/hoster/X7To.py @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- +from __future__ import with_statement + +import re + +from module.plugins.Hoster import Hoster + +from module.network.RequestFactory import getURL + +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" + result.append((url, 0, 1, url)) + continue + + # Name + fileInfo = re.search(' size: + self.handlePremium() + else: + self.handleFree() + + def handlePremium(self): + # check if over limit first + overLimit = re.search(r'', self.html) + if overLimit: + self.logDebug("over limit") + else: + realurl = re.search(r'', self.html) + if realurl: + realurl = 'http://stor' + realurl.group(1) + '.x7.to/dl/' + realurl.group(2) + 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 -- cgit v1.2.3