# -*- 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")