Repository navigation
Expand file tree
/
Copy pathUploadingCom.py
More file actions
65 lines (46 loc) · 1.9 KB
/
Copy pathUploadingCom.py
File metadata and controls
65 lines (46 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
import re
import time
from pyload.plugin.Account import Account
from pyload.plugin.internal.SimpleHoster import set_cookies
class UploadingCom(Account):
__name = "UploadingCom"
__type = "account"
__version = "0.12"
__description = """Uploading.com account plugin"""
__license = "GPLv3"
__authors = [("mkaay", "mkaay@mkaay.de")]
PREMIUM_PATTERN = r'UPGRADE TO PREMIUM'
VALID_UNTIL_PATTERN = r'Valid Until:(.+?)<'
def loadAccountInfo(self, user, req):
validuntil = None
trafficleft = None
premium = None
html = req.load("http://uploading.com/")
premium = re.search(self.PREMIUM_PATTERN, html) is None
m = re.search(self.VALID_UNTIL_PATTERN, html)
if m:
expiredate = m.group(1).strip()
self.logDebug("Expire date: " + expiredate)
try:
validuntil = time.mktime(time.strptime(expiredate, "%b %d, %Y"))
except Exception, e:
self.logError(e)
else:
if validuntil > time.mktime(time.gmtime()):
premium = True
else:
premium = False
validuntil = None
return {'validuntil' : validuntil,
'trafficleft': trafficleft,
'premium' : premium}
def login(self, user, data, req):
set_cookies(req.cj,
[("uploading.com", "lang" , "1" ),
("uploading.com", "language", "1" ),
("uploading.com", "setlang" , "en"),
("uploading.com", "_lang" , "en")])
req.load("http://uploading.com/")
req.load("http://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time.time() * 1000),
post={'email': user, 'password': data['password'], 'remember': "on"})