From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 76aff54f0..b58eaf15c 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: zoidberg """ import re @@ -28,6 +26,7 @@ class XFSPAccount(Account): __name__ = "XFSPAccount" __version__ = "0.06" __type__ = "account" + __description__ = """XFileSharingPro base account plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" @@ -39,6 +38,7 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|>Error<' PREMIUM_PATTERN = r'>Renew premium<' + def loadAccountInfo(self, user, req): html = req.load(self.MAIN_PAGE + "?op=my_account", decode=True) -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/internal/XFSPAccount.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index b58eaf15c..a1cba9af3 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -45,19 +45,19 @@ class XFSPAccount(Account): validuntil = trafficleft = None premium = True if re.search(self.PREMIUM_PATTERN, html) else False - found = re.search(self.VALID_UNTIL_PATTERN, html) - if found: + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: premium = True trafficleft = -1 try: - self.logDebug(found.group(1)) - validuntil = mktime(strptime(found.group(1), "%d %B %Y")) + self.logDebug(m.group(1)) + validuntil = mktime(strptime(m.group(1), "%d %B %Y")) except Exception, e: self.logError(e) else: - found = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if found: - trafficleft = found.group(1) + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = m.group(1) if "Unlimited" in trafficleft: premium = True else: -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/internal/XFSPAccount.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index a1cba9af3..5c0bfc893 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -1,22 +1,9 @@ # -*- 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 . -""" - import re + from time import mktime, strptime + from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm from module.utils import parseFileSize @@ -24,8 +11,8 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" - __version__ = "0.06" __type__ = "account" + __version__ = "0.06" __description__ = """XFileSharingPro base account plugin""" __author_name__ = "zoidberg" -- cgit v1.2.3 From 56971d70884e7d4f3242e7c52da88c4298ba130a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 5 Oct 2014 02:26:08 +0200 Subject: [XFSPAccount] COOKIES attribute support --- module/plugins/internal/XFSPAccount.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 5c0bfc893..b93fb5d30 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -5,20 +5,23 @@ import re from time import mktime, strptime from module.plugins.Account import Account -from module.plugins.internal.SimpleHoster import parseHtmlForm +from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.06" + __version__ = "0.07" __description__ = """XFileSharingPro base account plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" - MAIN_PAGE = None + + HOSTER_URL = None + + COOKIES = None #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:([^<]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:([^<]+)' @@ -27,7 +30,7 @@ class XFSPAccount(Account): def loadAccountInfo(self, user, req): - html = req.load(self.MAIN_PAGE + "?op=my_account", decode=True) + html = req.load(self.HOSTER_URL + "?op=my_account", decode=True) validuntil = trafficleft = None premium = True if re.search(self.PREMIUM_PATTERN, html) else False @@ -52,18 +55,21 @@ class XFSPAccount(Account): return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + def login(self, user, data, req): - html = req.load('%slogin.html' % self.MAIN_PAGE, decode=True) + set_cookies(req.cj, self.COOKIES) + + html = req.load('%slogin.html' % self.HOSTER_URL, decode=True) action, inputs = parseHtmlForm('name="FL"', html) if not inputs: inputs = {"op": "login", - "redirect": self.MAIN_PAGE} + "redirect": self.HOSTER_URL} inputs.update({"login": user, "password": data['password']}) - html = req.load(self.MAIN_PAGE, post=inputs, decode=True) + html = req.load(self.HOSTER_URL, post=inputs, decode=True) if re.search(self.LOGIN_FAIL_PATTERN, html): self.wrongPassword() -- cgit v1.2.3 From ec72263da9135c57e628bbaad4aa570f3df02fe0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 6 Oct 2014 13:23:26 +0200 Subject: [XFSPAccount] Improve patterns --- module/plugins/internal/XFSPAccount.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index b93fb5d30..434bf8d22 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -2,6 +2,7 @@ import re +from urlparse import urljoin from time import mktime, strptime from module.plugins.Account import Account @@ -12,25 +13,25 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.07" + __version__ = "0.08" __description__ = """XFileSharingPro base account plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __author_name__ = ("zoidberg", "Walter Purcaro") + __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com") HOSTER_URL = None COOKIES = None #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:([^<]+)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:([^<]+)' - LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|>Error<' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?(.+?)' + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' PREMIUM_PATTERN = r'>Renew premium<' def loadAccountInfo(self, user, req): - html = req.load(self.HOSTER_URL + "?op=my_account", decode=True) + html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) validuntil = trafficleft = None premium = True if re.search(self.PREMIUM_PATTERN, html) else False @@ -53,21 +54,22 @@ class XFSPAccount(Account): else: trafficleft = parseFileSize(trafficleft) / 1024 - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} def login(self, user, data, req): set_cookies(req.cj, self.COOKIES) - html = req.load('%slogin.html' % self.HOSTER_URL, decode=True) + url = urljoin(self.HOSTER_URL, "login.html") + html = req.load(url, decode=True) action, inputs = parseHtmlForm('name="FL"', html) if not inputs: - inputs = {"op": "login", - "redirect": self.HOSTER_URL} + inputs = {'op': "login", + 'redirect': self.HOSTER_URL} - inputs.update({"login": user, - "password": data['password']}) + inputs.update({'login': user, + 'password': data['password']}) html = req.load(self.HOSTER_URL, post=inputs, decode=True) -- cgit v1.2.3 From 261711415e971062bdb6ce495cfe5024faf75abc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 13:09:15 +0200 Subject: [XFSPAccount] Improve loadAccountInfo --- module/plugins/internal/XFSPAccount.py | 49 +++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 434bf8d22..f8440b0b2 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.08" + __version__ = "0.09" __description__ = """XFileSharingPro base account plugin""" __author_name__ = ("zoidberg", "Walter Purcaro") @@ -25,34 +25,53 @@ class XFSPAccount(Account): COOKIES = None #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?(.+?)' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?(?P.+?)' LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' - PREMIUM_PATTERN = r'>Renew premium<' + # PREMIUM_PATTERN = r'>Renew premium<' def loadAccountInfo(self, user, req): html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) - validuntil = trafficleft = None - premium = True if re.search(self.PREMIUM_PATTERN, html) else False + validuntil = None + trafficleft = None + premium = None + + if hasattr(self, "PREMIUM_PATTERN"): + premium = True if re.search(self.PREMIUM_PATTERN, html) else False m = re.search(self.VALID_UNTIL_PATTERN, html) if m: - premium = True - trafficleft = -1 + expiredate = m.group(1) + self.logDebug("Expire date: " + expiredate) + try: - self.logDebug(m.group(1)) - validuntil = mktime(strptime(m.group(1), "%d %B %Y")) + validuntil = mktime(strptime(expiredate, "%d %B %Y")) except Exception, e: self.logError(e) - else: - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - trafficleft = m.group(1) - if "Unlimited" in trafficleft: + else: + if validuntil > mktime(gmtime()): premium = True + trafficleft = -1 else: - trafficleft = parseFileSize(trafficleft) / 1024 + if premium is False: #: registered account type (not premium) + validuntil = -1 + premium = False + + try: + traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict() + trafficsize = traffic['S'] + traffic['U'] if 'U' in traffic else traffic['S'] + if "Unlimited" in trafficsize: + trafficleft = -1 + if premium is None: + premium = True + else: + trafficleft = parseFileSize(trafficsize) + except: + pass + + if premium is None: + premium = False return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index f8440b0b2..b2fb6179e 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -16,8 +16,8 @@ class XFSPAccount(Account): __version__ = "0.09" __description__ = """XFileSharingPro base account plugin""" - __author_name__ = ("zoidberg", "Walter Purcaro") - __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com") + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] HOSTER_URL = None -- cgit v1.2.3 From 0e9ba8a76e88ee98497db8dc7f25d8d160f10fa4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 00:30:48 +0200 Subject: [XFSPAccount] Fix missing COOKIE typecheck --- module/plugins/internal/XFSPAccount.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index b2fb6179e..2cda54615 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.09" + __version__ = "0.10" __description__ = """XFileSharingPro base account plugin""" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), @@ -77,7 +77,8 @@ class XFSPAccount(Account): def login(self, user, data, req): - set_cookies(req.cj, self.COOKIES) + if isinstance(self.COOKIES, list): + set_cookies(req.cj, self.COOKIES) url = urljoin(self.HOSTER_URL, "login.html") html = req.load(url, decode=True) -- cgit v1.2.3 From 1c4bd7a76450052b28dba609c04c5c4fcad0d014 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 16:34:26 +0200 Subject: [XFileSharingPro] Restore --- module/plugins/internal/XFSPAccount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 2cda54615..fdbd8829c 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -15,7 +15,7 @@ class XFSPAccount(Account): __type__ = "account" __version__ = "0.10" - __description__ = """XFileSharingPro base account plugin""" + __description__ = """XFileSharingPro account plugin""" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/internal/XFSPAccount.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index fdbd8829c..18543b9cd 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -16,6 +16,7 @@ class XFSPAccount(Account): __version__ = "0.10" __description__ = """XFileSharingPro account plugin""" + __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 93106fbef7579707e2918bcd9694e4a21b37d390 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 15 Oct 2014 02:04:25 +0200 Subject: [XFSPAccount] Improve TRAFFIC_LEFT_PATTERN --- module/plugins/internal/XFSPAccount.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 18543b9cd..9191b71a0 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.10" + __version__ = "0.11" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -26,8 +26,12 @@ class XFSPAccount(Account): COOKIES = None #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?(?P.+?)' + + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?P[\w^_]+)\s*' + TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + # PREMIUM_PATTERN = r'>Renew premium<' @@ -61,13 +65,18 @@ class XFSPAccount(Account): try: traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict() - trafficsize = traffic['S'] + traffic['U'] if 'U' in traffic else traffic['S'] - if "Unlimited" in trafficsize: + if "Unlimited" in traffic['S']: trafficleft = -1 if premium is None: premium = True else: - trafficleft = parseFileSize(trafficsize) + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = None + trafficleft = parseFileSize(traffic['S'], unit) except: pass -- cgit v1.2.3 From 268b16c9ecc588e6e884749e3fe715431367d1c9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 15 Oct 2014 13:42:32 +0200 Subject: [XFSPAccount] Fix TRAFFIC_LEFT_PATTERN --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 9191b71a0..f75422ca1 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.11" + __version__ = "0.12" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -27,7 +27,7 @@ class XFSPAccount(Account): VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?P[\w^_]+)\s*' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' -- cgit v1.2.3 From 5224a71f0dc30d640754a9fa64c7c54fa3ec4fb9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 13:48:21 +0200 Subject: [XFSPAccount] Set HOSTER_NAME (instead HOSTER_URL) as the mandatory attribute --- module/plugins/internal/XFSPAccount.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index f75422ca1..713bf827d 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.12" + __version__ = "0.13" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -21,9 +21,19 @@ class XFSPAccount(Account): ("Walter Purcaro", "vuolter@gmail.com")] - HOSTER_URL = None + """ + Following patterns should be defined by each hoster: - COOKIES = None #: or list of tuples [(domain, name, value)] + HOSTER_URL: (optional) + example: HOSTER_URL = r'linestorage.com' + + PREMIUM_PATTERN: (optional) Checks if the account is premium + example: PREMIUM_PATTERN = r'>Renew premium<' + """ + + HOSTER_NAME = None + + COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' @@ -32,7 +42,10 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' - # PREMIUM_PATTERN = r'>Renew premium<' + + def init(self): + if not hasattr(self, "HOSTER_URL"): + self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME def loadAccountInfo(self, user, req): -- cgit v1.2.3 From f70cd18b0c7cb303597a06becc791035f7fd7bd6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 20 Oct 2014 02:20:56 +0200 Subject: [XFSPAccount] Fixed broken login due missing HOSTER_URL --- module/plugins/internal/XFSPAccount.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 713bf827d..c2d779c29 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.13" + __version__ = "0.14" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -43,6 +43,11 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 + self.init() + return super(XFSPAccount, self).__init__(manager, accounts) + + def init(self): if not hasattr(self, "HOSTER_URL"): self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME -- cgit v1.2.3 From e41f3d7f9bac5c5923d5e3e4ae4b373f6c90dc16 Mon Sep 17 00:00:00 2001 From: guidobelix Date: Wed, 22 Oct 2014 21:41:11 +0200 Subject: Broken TRAFFIC_LEFT_PATTERN in RapidfileshareNet and TusfilesNet account --- module/plugins/internal/XFSPAccount.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index c2d779c29..d420adbb6 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -98,10 +98,7 @@ class XFSPAccount(Account): except: pass - if premium is None: - premium = False - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} def login(self, user, data, req): -- cgit v1.2.3 From 822fc8edc732248e5e79bf5a0ef9555bcc56b21c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 23:08:05 +0200 Subject: [XFSPAccount] Better HOSTER_URL --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index d420adbb6..5e2a0afc4 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.14" + __version__ = "0.15" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class XFSPAccount(Account): def init(self): if not hasattr(self, "HOSTER_URL"): - self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME + self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) def loadAccountInfo(self, user, req): -- cgit v1.2.3 From 29de13dc5098cc9214f3f8f111da140a22e3e2ff Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 01:15:58 +0200 Subject: Use parseTraffic instead parseFileSize in accounts --- module/plugins/internal/XFSPAccount.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 5e2a0afc4..e54fda987 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -7,13 +7,12 @@ from time import mktime, strptime from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies -from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.15" + __version__ = "0.16" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -94,7 +93,7 @@ class XFSPAccount(Account): unit = self.TRAFFIC_LEFT_UNIT else: unit = None - trafficleft = parseFileSize(traffic['S'], unit) + trafficleft = self.parseTraffic(traffic['S'], unit) except: pass -- cgit v1.2.3 From e92919794e2c7e49e015fee8dfc906404fa0e541 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 19:35:43 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index e54fda987..69b5cfc22 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.16" + __version__ = "0.17" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found -- cgit v1.2.3 From aa0751bcfd995e308bcd586a6965c75e68b1274b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:05:13 +0100 Subject: Code cosmetics --- module/plugins/internal/XFSPAccount.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 69b5cfc22..574bdd920 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -10,14 +10,14 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): - __name__ = "XFSPAccount" - __type__ = "account" + __name__ = "XFSPAccount" + __type__ = "account" __version__ = "0.17" __description__ = """XFileSharingPro account plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] """ -- cgit v1.2.3 From 483febe8e8711e644593ca758d1ba4c02c4dfde7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:10:50 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN --- module/plugins/internal/XFSPAccount.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 574bdd920..7b6215653 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.17" + __version__ = "0.18" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found @@ -64,7 +64,7 @@ class XFSPAccount(Account): m = re.search(self.VALID_UNTIL_PATTERN, html) if m: - expiredate = m.group(1) + expiredate = m.group(1).strip() self.logDebug("Expire date: " + expiredate) try: -- cgit v1.2.3 From c6c902698bb62f845e7be3156ec6b62d74200fec Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:15:36 +0100 Subject: [XFSPAccount] Fix missing gmtime import --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 7b6215653..ec62e5c1e 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -3,7 +3,7 @@ import re from urlparse import urljoin -from time import mktime, strptime +from time import gmtime, mktime, strptime from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.18" + __version__ = "0.19" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 97cf4aee358bf95d5e77b5efd4e9e470c9631185 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:00:09 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN 2 --- module/plugins/internal/XFSPAccount.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index ec62e5c1e..5f15a4659 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.19" + __version__ = "0.20" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{2} [\w^_]+ \d{4})' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found @@ -70,7 +70,7 @@ class XFSPAccount(Account): try: validuntil = mktime(strptime(expiredate, "%d %B %Y")) except Exception, e: - self.logError(e) + self.logError(str(e)) else: if validuntil > mktime(gmtime()): premium = True -- cgit v1.2.3 From 227a0eb5157875e75a385118ec3485b044ccdb8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 21:55:21 +0100 Subject: Improve loadAccountInfo stuff --- module/plugins/internal/XFSPAccount.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 5f15a4659..db8f92aec 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.20" + __version__ = "0.21" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -27,7 +27,7 @@ class XFSPAccount(Account): example: HOSTER_URL = r'linestorage.com' PREMIUM_PATTERN: (optional) Checks if the account is premium - example: PREMIUM_PATTERN = r'>Renew premium<' + example: PREMIUM_PATTERN = r'>Renew premium' """ HOSTER_NAME = None @@ -74,7 +74,6 @@ class XFSPAccount(Account): else: if validuntil > mktime(gmtime()): premium = True - trafficleft = -1 else: if premium is False: #: registered account type (not premium) validuntil = -1 -- cgit v1.2.3 From 71be42ba4635ef49c1cc7690be8805f00bc35e3c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Oct 2014 17:23:18 +0100 Subject: [XFSPAccount] Fix and improve loadAccountInfo --- module/plugins/internal/XFSPAccount.py | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index db8f92aec..381e919e6 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.21" + __version__ = "0.22" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,9 +34,9 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{2} [\w^_]+ \d{4})' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+|[Uu]nlimited)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' @@ -48,6 +48,9 @@ class XFSPAccount(Account): def init(self): + # if not self.HOSTER_NAME: + # self.fail(_("Missing HOSTER_NAME")) + if not hasattr(self, "HOSTER_URL"): self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) @@ -79,22 +82,26 @@ class XFSPAccount(Account): validuntil = -1 premium = False - try: - traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict() - if "Unlimited" in traffic['S']: - trafficleft = -1 - if premium is None: - premium = True - else: - if 'U' in traffic: - unit = traffic['U'] - elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): - unit = self.TRAFFIC_LEFT_UNIT + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + traffic = m.groupdict() + if "nlimited" in traffic['S']: + trafficleft = -1 + if premium is None: + premium = True else: - unit = None - trafficleft = self.parseTraffic(traffic['S'], unit) - except: - pass + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = "" + + trafficleft = self.parseTraffic(traffic['S'] + unit) + + except Exception, e: + self.logDebug(str(e)) return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} -- cgit v1.2.3 From 7e759ef2d5dbb30da9752b72146bf4ff240821a8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 2 Nov 2014 22:34:38 +0100 Subject: Update internal XFS plugins --- module/plugins/internal/XFSPAccount.py | 127 --------------------------------- 1 file changed, 127 deletions(-) delete mode 100644 module/plugins/internal/XFSPAccount.py (limited to 'module/plugins/internal/XFSPAccount.py') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py deleted file mode 100644 index 381e919e6..000000000 --- a/module/plugins/internal/XFSPAccount.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin -from time import gmtime, mktime, strptime - -from module.plugins.Account import Account -from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies - - -class XFSPAccount(Account): - __name__ = "XFSPAccount" - __type__ = "account" - __version__ = "0.22" - - __description__ = """XFileSharingPro account plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - """ - Following patterns should be defined by each hoster: - - HOSTER_URL: (optional) - example: HOSTER_URL = r'linestorage.com' - - PREMIUM_PATTERN: (optional) Checks if the account is premium - example: PREMIUM_PATTERN = r'>Renew premium' - """ - - HOSTER_NAME = None - - COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' - - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+|[Uu]nlimited)\s*(?:(?P[\w^_]+)\s*)?' - TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found - - LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' - - - def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 - self.init() - return super(XFSPAccount, self).__init__(manager, accounts) - - - def init(self): - # if not self.HOSTER_NAME: - # self.fail(_("Missing HOSTER_NAME")) - - if not hasattr(self, "HOSTER_URL"): - self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) - - - def loadAccountInfo(self, user, req): - html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) - - validuntil = None - trafficleft = None - premium = None - - if hasattr(self, "PREMIUM_PATTERN"): - premium = True if re.search(self.PREMIUM_PATTERN, html) else False - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1).strip() - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%d %B %Y")) - except Exception, e: - self.logError(str(e)) - else: - if validuntil > mktime(gmtime()): - premium = True - else: - if premium is False: #: registered account type (not premium) - validuntil = -1 - premium = False - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - try: - traffic = m.groupdict() - if "nlimited" in traffic['S']: - trafficleft = -1 - if premium is None: - premium = True - else: - if 'U' in traffic: - unit = traffic['U'] - elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): - unit = self.TRAFFIC_LEFT_UNIT - else: - unit = "" - - trafficleft = self.parseTraffic(traffic['S'] + unit) - - except Exception, e: - self.logDebug(str(e)) - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} - - - def login(self, user, data, req): - if isinstance(self.COOKIES, list): - set_cookies(req.cj, self.COOKIES) - - url = urljoin(self.HOSTER_URL, "login.html") - html = req.load(url, decode=True) - - action, inputs = parseHtmlForm('name="FL"', html) - if not inputs: - inputs = {'op': "login", - 'redirect': self.HOSTER_URL} - - inputs.update({'login': user, - 'password': data['password']}) - - html = req.load(self.HOSTER_URL, post=inputs, decode=True) - - if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrongPassword() -- cgit v1.2.3