summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/Api.py15
-rw-r--r--module/database/UserDatabase.py18
-rw-r--r--module/plugins/hoster/OronCom.py113
-rw-r--r--module/remote/thriftbackend/pyload.thrift3
-rwxr-xr-xmodule/remote/thriftbackend/thriftgen/pyload/Pyload-remote7
-rw-r--r--module/remote/thriftbackend/thriftgen/pyload/Pyload.py67
-rw-r--r--module/remote/thriftbackend/thriftgen/pyload/ttypes.py10
-rw-r--r--module/web/pyload_app.py3
-rw-r--r--module/web/templates/default/base.html4
9 files changed, 220 insertions, 20 deletions
diff --git a/module/Api.py b/module/Api.py
index e3a0dffed..b77cbfb0b 100644
--- a/module/Api.py
+++ b/module/Api.py
@@ -932,14 +932,23 @@ class Api(Iface):
return False
+ @permission(PERMS.ALL)
def getUserData(self, username, password):
- """see `checkAuth`"""
- return self.checkAuth(username, password)
+ """similar to `checkAuth` but returns UserData thrift type """
+ user = self.checkAuth(username, password)
+ if user:
+ return UserData(user["name"], user["email"], user["role"], user["permission"], user["template"])
+ else:
+ return UserData()
def getAllUserData(self):
"""returns all known user and info"""
- return self.core.db.getAllUserData()
+ res = {}
+ for user, data in self.core.db.getAllUserData().iteritems():
+ res[user] = UserData(user, data["email"], data["role"], data["permission"], data["template"])
+
+ return res
@permission(PERMS.STATUS)
def getServices(self):
diff --git a/module/database/UserDatabase.py b/module/database/UserDatabase.py
index e74399c11..0c781057d 100644
--- a/module/database/UserDatabase.py
+++ b/module/database/UserDatabase.py
@@ -26,25 +26,26 @@ class UserMethods():
@style.queue
def checkAuth(db, user, password):
c = db.c
- c.execute('SELECT id, name, password, role, permission, template FROM "users" WHERE name=?', (user, ))
+ c.execute('SELECT id, name, password, role, permission, template, email FROM "users" WHERE name=?', (user, ))
r = c.fetchone()
if not r:
return {}
-
+
salt = r[2][:5]
pw = r[2][5:]
h = sha1(salt + password)
if h.hexdigest() == pw:
- return {"id": r[0], "name": r[1], "role": r[3], "permission": r[4], "template": r[5]}
+ return {"id": r[0], "name": r[1], "role": r[3],
+ "permission": r[4], "template": r[5], "email": r[6]}
else:
return {}
-
+
@style.queue
def addUser(db, user, password):
salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)])
h = sha1(salt + password)
password = salt + h.hexdigest()
-
+
c = db.c
c.execute('SELECT name FROM users WHERE name=?', (user, ))
if c.fetchone() is not None:
@@ -55,7 +56,6 @@ class UserMethods():
@style.queue
def changePassword(db, user, oldpw, newpw):
-
db.c.execute('SELECT id, name, password FROM users WHERE name=?', (user, ))
r = db.c.fetchone()
if not r:
@@ -94,11 +94,11 @@ class UserMethods():
@style.queue
def getAllUserData(db):
- db.c.execute("SELECT name, permission, role FROM users")
+ db.c.execute("SELECT name, permission, role, template, email FROM users")
user = {}
for r in db.c:
- user[r[0]] = {"permission" : r[1], "role" : r[2]}
-
+ user[r[0]] = {"permission": r[1], "role": r[2], "template": r[3], "email": r[4]}
+
return user
@style.queue
diff --git a/module/plugins/hoster/OronCom.py b/module/plugins/hoster/OronCom.py
new file mode 100644
index 000000000..5f7cbd18b
--- /dev/null
+++ b/module/plugins/hoster/OronCom.py
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+import re
+
+from module.plugins.Hoster import Hoster
+from module.network.RequestFactory import getURL
+from module.plugins.ReCaptcha import ReCaptcha
+
+def getInfo(urls):
+ result = []
+
+ for url in urls:
+ html = getURL(url).replace("\n","")
+ html = html.replace("\t", "")
+ if "File could not be found" in html:
+ result.append((url, 0, 1, url))
+ continue
+
+ m = re.search(OronCom.FILE_INFO_PATTERN, html)
+ if m:
+ name = m.group(1)
+ hSize = float(m.group(2).replace(",", "."))
+ pow = {'Kb':1, 'Mb': 2, 'Gb':3}[m.group(3)]
+ size = int(hSize * 1024 ** pow)
+ else:
+ name = url
+ size = 0
+
+ result.append((name, size, 2, url))
+ yield result
+
+class OronCom(Hoster):
+ __name__ = "OronCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(?:www.)?oron.com/"
+ __version__ = "0.1"
+ __description__ = "File Hoster: Oron.com"
+ __author_name__ = "chrox"
+
+ FILE_INFO_PATTERN = r'<td align="right">.*?Filename: .*?>(.*?)</b><br>File size: ([0-9,.]+) (Kb|Mb|Gb)'
+
+ def init(self):
+ self.multiDL = False
+ self.file_id = re.search(r'http://(?:www.)?oron.com/([a-zA-Z0-9]+)', self.pyfile.url).group(1)
+ self.logDebug("File id is %s" % self.file_id)
+ self.pyfile.url = "http://oron.com/" + self.file_id
+
+ def process(self, pyfile):
+ self.html = self.load(self.pyfile.url, ref=False, decode=True).replace("\n","")
+ if "File could not be found" in self.html:
+ self.offline()
+ self.html = self.html.replace("\t", "")
+ m = re.search(self.FILE_INFO_PATTERN, self.html)
+ if m:
+ pyfile.name = m.group(1)
+ hSize = float(m.group(2).replace(",", "."))
+ pow = {'Kb':1, 'Mb': 2, 'Gb':3}[m.group(3)]
+ pyfile.size = int(hSize * 1024 ** pow)
+ self.logDebug("File Size: %d" % pyfile.size)
+ else:
+ self.logDebug("Name and/or size not found.")
+
+ self.handleFree(pyfile)
+
+ def handleFree(self, pyfile):
+ self.html = self.load(self.pyfile.url, ref=False, decode=True).replace("\n","")
+ if "download1" in self.html:
+ post_url = "http://oron.com/"+self.file_id
+ post_dict = {'op': 'download1', 'usr_login': '', 'id':self.file_id, 'fname':pyfile.name, 'referer':'', 'method_free':' Regular Download '}
+ self.html = self.load(post_url, post=post_dict, ref=False, decode=True).encode("utf-8")
+ if '<p class="err">' in self.html:
+ time_list = re.findall(r'\d+(?=\s[a-z]+,)|\d+(?=\s.*?until)',self.html)
+ tInSec = 0
+ for t in time_list:
+ tInSec = tInSec + int(t)*60**(len(time_list)-time_list.index(t)-1)
+ self.setWait(tInSec,True)
+ self.wait()
+ self.retry()
+
+ if "download2" in self.html:
+ post_dict['op'] = 'download2'
+ post_dict['method_free'] = 'Regular Download'
+ post_dict['method_premium'] = ''
+ post_dict['down_direct'] = '1'
+ post_dict['btn_download'] = ' Create Download Link '
+ del(post_dict['fname'])
+
+ re_captcha = ReCaptcha(self)
+ downloadLink = ""
+ for i in range(5):
+ m = re.search('name="rand" value="(.*?)">', self.html)
+ post_dict['rand'] = m.group(1)
+ challengeId = re.search(r'/recaptcha/api/challenge[?k=]+([^"]+)', self.html)
+ challenge, result = re_captcha.challenge(challengeId.group(1))
+ post_dict['recaptcha_challenge_field'] = challenge
+ post_dict['recaptcha_response_field'] = result
+ self.html = self.load(post_url, post=post_dict)
+ m = re.search('<p class="err">(.*?)</p>', self.html)
+ if m:
+ if m.group(1) == "Wrong captcha":
+ self.invalidCaptcha()
+ self.logDebug("Captcha failed")
+ if 'class="atitle">Download File' in self.html:
+ self.correctCaptcha()
+ downloadLink = re.search('href="(.*?)" class="atitle"',self.html)
+ break
+
+ if not downloadLink:
+ self.fail("Could not find download link")
+
+ self.logDebug("Download url found: %s" % downloadLink.group(1))
+ self.download(downloadLink.group(1))
+ else:
+ self.logError("error in parsing site")
diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift
index 128ba6240..03eb1d4eb 100644
--- a/module/remote/thriftbackend/pyload.thrift
+++ b/module/remote/thriftbackend/pyload.thrift
@@ -130,7 +130,7 @@ struct UserData {
2: string email,
3: i32 role,
4: i32 permission,
- 5: string template
+ 5: string templateName
}
struct AccountInfo {
@@ -276,6 +276,7 @@ service Pyload {
//auth
bool login(1: string username, 2: string password),
UserData getUserData(1: string username, 2:string password),
+ map<string, UserData> getAllUserData(),
//services
diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote
index 0251fbeae..8c3390438 100755
--- a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote
+++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote
@@ -87,6 +87,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ' void removeAccount(PluginName plugin, string account)'
print ' bool login(string username, string password)'
print ' UserData getUserData(string username, string password)'
+ print ' getAllUserData()'
print ' getServices()'
print ' bool hasService(PluginName plugin, string func)'
print ' string call(ServiceCall info)'
@@ -526,6 +527,12 @@ elif cmd == 'getUserData':
sys.exit(1)
pp.pprint(client.getUserData(args[0],args[1],))
+elif cmd == 'getAllUserData':
+ if len(args) != 0:
+ print 'getAllUserData requires 0 args'
+ sys.exit(1)
+ pp.pprint(client.getAllUserData())
+
elif cmd == 'getServices':
if len(args) != 0:
print 'getServices requires 0 args'
diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py
index eef9e38e5..d54cfaedd 100644
--- a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py
+++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py
@@ -395,6 +395,9 @@ class Iface(object):
"""
pass
+ def getAllUserData(self, ):
+ pass
+
def getServices(self, ):
pass
@@ -2242,6 +2245,31 @@ class Client(Iface):
return result.success
raise TApplicationException(TApplicationException.MISSING_RESULT, "getUserData failed: unknown result");
+ def getAllUserData(self, ):
+ self.send_getAllUserData()
+ return self.recv_getAllUserData()
+
+ def send_getAllUserData(self, ):
+ self._oprot.writeMessageBegin('getAllUserData', TMessageType.CALL, self._seqid)
+ args = getAllUserData_args()
+ args.write(self._oprot)
+ self._oprot.writeMessageEnd()
+ self._oprot.trans.flush()
+
+ def recv_getAllUserData(self, ):
+ (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+ if mtype == TMessageType.EXCEPTION:
+ x = TApplicationException()
+ x.read(self._iprot)
+ self._iprot.readMessageEnd()
+ raise x
+ result = getAllUserData_result()
+ result.read(self._iprot)
+ self._iprot.readMessageEnd()
+ if result.success is not None:
+ return result.success
+ raise TApplicationException(TApplicationException.MISSING_RESULT, "getAllUserData failed: unknown result");
+
def getServices(self, ):
self.send_getServices()
return self.recv_getServices()
@@ -2457,6 +2485,7 @@ class Processor(Iface, TProcessor):
self._processMap["removeAccount"] = Processor.process_removeAccount
self._processMap["login"] = Processor.process_login
self._processMap["getUserData"] = Processor.process_getUserData
+ self._processMap["getAllUserData"] = Processor.process_getAllUserData
self._processMap["getServices"] = Processor.process_getServices
self._processMap["hasService"] = Processor.process_hasService
self._processMap["call"] = Processor.process_call
@@ -3194,6 +3223,17 @@ class Processor(Iface, TProcessor):
oprot.writeMessageEnd()
oprot.trans.flush()
+ def process_getAllUserData(self, seqid, iprot, oprot):
+ args = getAllUserData_args()
+ args.read(iprot)
+ iprot.readMessageEnd()
+ result = getAllUserData_result()
+ result.success = self._handler.getAllUserData()
+ oprot.writeMessageBegin("getAllUserData", TMessageType.REPLY, seqid)
+ result.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+
def process_getServices(self, seqid, iprot, oprot):
args = getServices_args()
args.read(iprot)
@@ -5278,6 +5318,33 @@ class getUserData_result(TBase):
self.success = success
+class getAllUserData_args(TBase):
+
+ __slots__ = [
+ ]
+
+ thrift_spec = (
+ )
+
+
+class getAllUserData_result(TBase):
+ """
+ Attributes:
+ - success
+ """
+
+ __slots__ = [
+ 'success',
+ ]
+
+ thrift_spec = (
+ (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(UserData, UserData.thrift_spec)), None, ), # 0
+ )
+
+ def __init__(self, success=None,):
+ self.success = success
+
+
class getServices_args(TBase):
__slots__ = [
diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
index 78b2acc09..204090577 100644
--- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
+++ b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
@@ -472,7 +472,7 @@ class UserData(TBase):
- email
- role
- permission
- - template
+ - templateName
"""
__slots__ = [
@@ -480,7 +480,7 @@ class UserData(TBase):
'email',
'role',
'permission',
- 'template',
+ 'templateName',
]
thrift_spec = (
@@ -489,15 +489,15 @@ class UserData(TBase):
(2, TType.STRING, 'email', None, None, ), # 2
(3, TType.I32, 'role', None, None, ), # 3
(4, TType.I32, 'permission', None, None, ), # 4
- (5, TType.STRING, 'template', None, None, ), # 5
+ (5, TType.STRING, 'templateName', None, None, ), # 5
)
- def __init__(self, name=None, email=None, role=None, permission=None, template=None,):
+ def __init__(self, name=None, email=None, role=None, permission=None, templateName=None,):
self.name = name
self.email = email
self.role = role
self.permission = permission
- self.template = template
+ self.templateName = templateName
class AccountInfo(TBase):
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index 553eeaa57..0370e19cb 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -470,7 +470,8 @@ def logs(item=-1):
@route("/admin", method="POST")
@login_required("ADMIN")
def admin():
- user = PYLOAD.getAllUserData()
+ # convert to dict
+ user = dict([(name, toDict(y)) for name, y in PYLOAD.getAllUserData().iteritems()])
perms = permlist()
for data in user.itervalues():
diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html
index 2987cf081..c7014e6b6 100644
--- a/module/web/templates/default/base.html
+++ b/module/web/templates/default/base.html
@@ -148,7 +148,9 @@ function out(){
function show_cap(){
bg_show();
$("cap_box").setStyle('display', 'block');
- cap_box.start('opacity',1)
+ cap_box.start('opacity',1).chain(function(){
+ $('cap_result').focus();
+ });
}
function hide_cap(){