summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/UploadingCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/accounts/UploadingCom.py')
-rw-r--r--module/plugins/accounts/UploadingCom.py76
1 files changed, 42 insertions, 34 deletions
diff --git a/module/plugins/accounts/UploadingCom.py b/module/plugins/accounts/UploadingCom.py
index f07c2941a..c70d2ec11 100644
--- a/module/plugins/accounts/UploadingCom.py
+++ b/module/plugins/accounts/UploadingCom.py
@@ -1,55 +1,63 @@
# -*- coding: utf-8 -*-
-"""
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-"""
+import re
from time import time, strptime, mktime
-import re
from module.plugins.Account import Account
+from module.plugins.internal.SimpleHoster import set_cookies
class UploadingCom(Account):
- __name__ = "UploadingCom"
- __version__ = "0.1"
- __type__ = "account"
+ __name__ = "UploadingCom"
+ __type__ = "account"
+ __version__ = "0.11"
__description__ = """Uploading.com account plugin"""
- __author_name__ = "mkaay"
- __author_mail__ = "mkaay@mkaay.de"
+ __license__ = "GPLv3"
+ __authors__ = [("mkaay", "mkaay@mkaay.de")]
+
+
+ PREMIUM_PATTERN = r'UPGRADE TO PREMIUM'
+ VALID_UNTIL_PATTERN = r'Valid Until:(.+?)<'
def loadAccountInfo(self, user, req):
- src = req.load("http://uploading.com/")
- premium = True
- if "UPGRADE TO PREMIUM" in src:
- return {"validuntil": -1, "trafficleft": -1, "premium": False}
+ validuntil = None
+ trafficleft = None
+ premium = None
+
+ html = req.load("http://uploading.com/")
- m = re.search("Valid Until:(.*?)<", src)
+ premium = False if re.search(self.PREMIUM_PATTERN, html) else True
+
+ m = re.search(self.VALID_UNTIL_PATTERN, html)
if m:
- validuntil = int(mktime(strptime(m.group(1).strip(), "%b %d, %Y")))
- else:
- validuntil = -1
+ expiredate = m.group(1).strip()
+ self.logDebug("Expire date: " + expiredate)
+
+ try:
+ validuntil = mktime(strptime(expiredate, "%b %d, %Y"))
+
+ except Exception, e:
+ self.logError(e)
+
+ else:
+ if validuntil > mktime(gmtime()):
+ premium = True
+ else:
+ premium = False
+ validuntil = None
+
+ return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium}
- return {"validuntil": validuntil, "trafficleft": -1, "premium": True}
def login(self, user, data, req):
- req.cj.setCookie("uploading.com", "lang", "1")
- req.cj.setCookie("uploading.com", "language", "1")
- req.cj.setCookie("uploading.com", "setlang", "en")
- req.cj.setCookie("uploading.com", "_lang", "en")
+ set_cookies([("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() * 1000),
- post={"email": user, "password": data['password'], "remember": "on"})
+ post={'email': user, 'password': data['password'], 'remember': "on"})