summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-11 13:52:11 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-11 13:52:11 +0200
commitee5f77de01779850b61561be2f6146e7cdc148ae (patch)
tree65cbeed509e2d15cd472d621d27ab3443c7d2ab8 /module
parentMerge pull request #785 from marley2013/patch-4 (diff)
downloadpyload-ee5f77de01779850b61561be2f6146e7cdc148ae.tar.xz
[CatShareNet] Account support
Diffstat (limited to 'module')
-rw-r--r--module/plugins/accounts/CatShareNet.py56
-rw-r--r--module/plugins/hoster/CatShareNet.py6
2 files changed, 59 insertions, 3 deletions
diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py
new file mode 100644
index 000000000..89c80e2b4
--- /dev/null
+++ b/module/plugins/accounts/CatShareNet.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+from time import mktime, strptime
+
+from module.plugins.Account import Account
+
+
+class CatShareNet(Account):
+ __name__ = "CatShareNet"
+ __type__ = "account"
+ __version__ = "0.01"
+
+ __description__ = """CatShareNet account plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("prOq", None)]
+
+
+ PREMIUM_PATTERN = r'class="nav-collapse collapse pull-right">[\s\w<>=-."/:]*\sz.</a></li>\s*<li><a href="/premium">.*\s*<span style="color: red">(.*?)</span>[\s\w<>/]*href="/logout"'
+ VALID_UNTIL_PATTERN = r'<div class="span6 pull-right">[\s\w<>=-":;]*<span style="font-size:13px;">.*?<strong>(.*?)</strong></span>'
+
+
+ def loadAccountInfo(self, user, req):
+ premium = False
+ validuntil = -1
+
+ html = req.load("http://catshare.net/", decode=True)
+
+ try:
+ m = re.search(self.PREMIUM_PATTERN, html)
+ if "Premium" in m.group(1):
+ premium = True
+ except:
+ pass
+
+ try:
+ m = re.search(self.VALID_UNTIL_PATTERN, html)
+ expiredate = m.group(1)
+ if "-" not in expiredate:
+ validuntil = mktime(strptime(expiredate, "%d.%m.%Y"))
+ except:
+ pass
+
+ return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil}
+
+
+ def login(self, user, data, req):
+ html = req.load("http://catshare.net/login",
+ post={'user_email': user,
+ 'user_password': data['password'],
+ 'remindPassword': 0,
+ 'user[submit]': "Login"})
+
+ if not '<a href="/logout">Wyloguj</a>' in html:
+ self.wrongPassword()
diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py
index c50632ac3..0993c69e6 100644
--- a/module/plugins/hoster/CatShareNet.py
+++ b/module/plugins/hoster/CatShareNet.py
@@ -9,7 +9,7 @@ from module.plugins.internal.CaptchaService import ReCaptcha
class CatShareNet(SimpleHoster):
__name__ = "CatShareNet"
__type__ = "hoster"
- __version__ = "0.06"
+ __version__ = "0.07"
__pattern__ = r'http://(?:www\.)?catshare\.net/\w{16}'
@@ -23,9 +23,9 @@ class CatShareNet(SimpleHoster):
TEXT_ENCODING = True
FILE_INFO_PATTERN = r'<title>(?P<N>.+) \((?P<S>[\d.]+) (?P<U>\w+)\)<'
- OFFLINE_PATTERN = r'Podany plik został usunięty\s*</div>'
+ OFFLINE_PATTERN = ur'Podany plik został usunięty\s*</div>'
- IP_BLOCKED_PATTERN = r'>Nasz serwis wykrył że Twój adres IP nie pochodzi z Polski.<'
+ IP_BLOCKED_PATTERN = ur'>Nasz serwis wykrył że Twój adres IP nie pochodzi z Polski.<'
SECONDS_PATTERN = 'var\scount\s=\s(\d+);'
LINK_PATTERN = r'<form action="(.+?)" method="GET">'