diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-25 04:59:27 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-25 04:59:27 +0200 |
commit | 8f17f875f6e28f73ddb10da59c6464bd04922222 (patch) | |
tree | 29631cd1f81a40283c71dfdd005b9d24370d5d7f | |
parent | Fix typo (diff) | |
download | pyload-8f17f875f6e28f73ddb10da59c6464bd04922222.tar.xz |
Account rewritten
99 files changed, 486 insertions, 498 deletions
diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 290343bc1..0647892b0 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -20,8 +20,8 @@ class AlldebridCom(Account): __authors__ = [("Andy Voigt", "spamsales@online.de")] - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) html = self.load("http://www.alldebrid.com/account/") soup = BeautifulSoup.BeautifulSoup(html) @@ -38,11 +38,11 @@ class AlldebridCom(Account): #: Get expiration date from API except Exception: - data = self.get_account_data(user) + data = self.get_data(user) html = self.load("https://www.alldebrid.com/api.php", get={'action': "info_user", 'login' : user, - 'pw' : data['password']}) + 'pw' : password}) self.log_debug(html) @@ -54,13 +54,13 @@ class AlldebridCom(Account): 'premium' : True } - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://www.alldebrid.com/register/", get={'action' : "login", 'login_login' : user, - 'login_password': data['password']}) + 'login_password': password}) if "This login doesn't exist" in html \ or "The password is not valid" in html \ or "Invalid captcha" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/BitshareCom.py b/module/plugins/accounts/BitshareCom.py index 98de0cfbb..426468ee6 100644 --- a/module/plugins/accounts/BitshareCom.py +++ b/module/plugins/accounts/BitshareCom.py @@ -14,7 +14,7 @@ class BitshareCom(Account): __authors__ = [("Paul King", None)] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://bitshare.com/mysettings.html") if "\"http://bitshare.com/myupgrade.html\">Free" in html: @@ -26,11 +26,11 @@ class BitshareCom(Account): return {'validuntil': -1, 'trafficleft': -1, 'premium': True} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://bitshare.com/login.html", post={'user' : user, - 'password': data['password'], + 'password': password, 'submit' : "Login"}) if "login" in req.lastEffectiveURL: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py index 3cda27510..f198561f5 100644 --- a/module/plugins/accounts/CatShareNet.py +++ b/module/plugins/accounts/CatShareNet.py @@ -22,7 +22,7 @@ class CatShareNet(Account): TRAFFIC_LEFT_PATTERN = r'<a href="/premium">([0-9.]+ [kMG]B)' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = -1 trafficleft = -1 @@ -50,12 +50,12 @@ class CatShareNet(Account): return {'premium': premium, 'trafficleft': trafficleft, 'validuntil': validuntil} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://catshare.net/login", #@TODO: Revert to `https` in 0.4.10 post={'user_email' : user, - 'user_password' : data['password'], + 'user_password' : password, 'remindPassword': 0, 'user[submit]' : "Login"}) if not '<a href="/logout">Wyloguj</a>' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/CloudzillaTo.py b/module/plugins/accounts/CloudzillaTo.py index 056f72594..b6c65fc8c 100644 --- a/module/plugins/accounts/CloudzillaTo.py +++ b/module/plugins/accounts/CloudzillaTo.py @@ -19,7 +19,7 @@ class CloudzillaTo(Account): PREMIUM_PATTERN = r'<h2>account type</h2>\s*Premium Account' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.cloudzilla.to/") premium = True if re.search(self.PREMIUM_PATTERN, html) else False @@ -27,11 +27,11 @@ class CloudzillaTo(Account): return {'validuntil': -1, 'trafficleft': -1, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://www.cloudzilla.to/", post={'lusername': user, - 'lpassword': data['password'], + 'lpassword': password, 'w' : "dologin"}) if "ERROR" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py index 4b05155b5..4077b5909 100644 --- a/module/plugins/accounts/CzshareCom.py +++ b/module/plugins/accounts/CzshareCom.py @@ -21,7 +21,7 @@ class CzshareCom(Account): CREDIT_LEFT_PATTERN = r'<tr class="active">\s*<td>([\d ,]+) (KiB|MiB|GiB)</td>\s*<td>([^<]*)</td>\s*</tr>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = None trafficleft = None @@ -44,11 +44,11 @@ class CzshareCom(Account): 'trafficleft': trafficleft} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('https://sdilej.cz/index.php', post={'Prihlasit' : "Prihlasit", - "login-password": data['password'], + "login-password": password, "login-name" : user}) if '<div class="login' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/DebridItaliaCom.py b/module/plugins/accounts/DebridItaliaCom.py index 76ecdd467..cb9771769 100644 --- a/module/plugins/accounts/DebridItaliaCom.py +++ b/module/plugins/accounts/DebridItaliaCom.py @@ -21,7 +21,7 @@ class DebridItaliaCom(Account): WALID_UNTIL_PATTERN = r'Premium valid till: (.+?) \|' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): info = {'premium': False, 'validuntil': None, 'trafficleft': None} html = self.load("http://debriditalia.com/") @@ -36,10 +36,10 @@ class DebridItaliaCom(Account): return info - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://debriditalia.com/login.php", get={'u': user, - 'p': data['password']}) + 'p': password}) if 'NO' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/DepositfilesCom.py b/module/plugins/accounts/DepositfilesCom.py index 80e565dd6..398a2ac85 100644 --- a/module/plugins/accounts/DepositfilesCom.py +++ b/module/plugins/accounts/DepositfilesCom.py @@ -19,7 +19,7 @@ class DepositfilesCom(Account): ("Walter Purcaro", "vuolter@gmail.com")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("https://dfiles.eu/de/gold/") validuntil = re.search(r"Sie haben Gold Zugang bis: <b>(.*?)</b></div>", html).group(1) @@ -28,11 +28,11 @@ class DepositfilesCom(Account): return {'validuntil': validuntil, 'trafficleft': -1} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://dfiles.eu/de/login.php", get={'return': "/de/gold/payment.php"}, post={'login' : user, - 'password': data['password']}) + 'password': password}) if r'<div class="error_message">Sie haben eine falsche Benutzername-Passwort-Kombination verwendet.</div>' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/EuroshareEu.py b/module/plugins/accounts/EuroshareEu.py index 761644d8f..e61b8e853 100644 --- a/module/plugins/accounts/EuroshareEu.py +++ b/module/plugins/accounts/EuroshareEu.py @@ -17,7 +17,7 @@ class EuroshareEu(Account): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): self.relogin(user) html = self.load("http://euroshare.eu/customer-zone/settings/") @@ -32,11 +32,11 @@ class EuroshareEu(Account): return {'validuntil': validuntil, 'trafficleft': -1, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('http://euroshare.eu/customer-zone/login/', post={'trvale' : "1", 'login' : user, - 'password': data['password']}) + 'password': password}) if u">Nesprávne prihlasovacie meno alebo heslo" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FastixRu.py b/module/plugins/accounts/FastixRu.py index dc18290a5..91608c2ae 100644 --- a/module/plugins/accounts/FastixRu.py +++ b/module/plugins/accounts/FastixRu.py @@ -15,8 +15,8 @@ class FastixRu(Account): __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) html = json_loads(self.load("http://fastix.ru/api_v2/", get={'apikey': data['api'], 'sub' : "getaccountdetails"})) @@ -31,11 +31,11 @@ class FastixRu(Account): return account_info - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://fastix.ru/api_v2/", get={'sub' : "get_apikey", 'email' : user, - 'password': data['password']}) + 'password': password}) api = json_loads(html) api = api['apikey'] @@ -43,4 +43,4 @@ class FastixRu(Account): data['api'] = api if "error_code" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FastshareCz.py b/module/plugins/accounts/FastshareCz.py index 7afbd659e..119e26579 100644 --- a/module/plugins/accounts/FastshareCz.py +++ b/module/plugins/accounts/FastshareCz.py @@ -20,7 +20,7 @@ class FastshareCz(Account): CREDIT_PATTERN = r'Credit\s*:\s*</td>\s*<td>(.+?)\s*<' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = -1 trafficleft = None premium = False @@ -38,14 +38,14 @@ class FastshareCz(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("fastshare.cz", "lang", "en") self.load('http://www.fastshare.cz/login') #@NOTE: Do not remove or it will not login html = self.load("https://www.fastshare.cz/sql.php", post={'login': user, - 'heslo': data['password']}) + 'heslo': password}) if ">Wrong username or password" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FilecloudIo.py b/module/plugins/accounts/FilecloudIo.py index 021160f03..fb61e507c 100644 --- a/module/plugins/accounts/FilecloudIo.py +++ b/module/plugins/accounts/FilecloudIo.py @@ -16,11 +16,11 @@ class FilecloudIo(Account): ("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): #: It looks like the first API request always fails, so we retry 5 times, it should work on the second try for _i in xrange(5): rep = self.load("https://secure.filecloud.io/api-fetch_apikey.api", - post={'username': user, 'password': self.get_account_data(user)['password']}) + post={'username': user, 'password': self.get_data(user)['password']}) rep = json_loads(rep) if rep['status'] == "ok": break @@ -42,7 +42,7 @@ class FilecloudIo(Account): return {'premium': False} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("secure.filecloud.io", "lang", "en") html = self.load('https://secure.filecloud.io/user-login.html') @@ -50,10 +50,10 @@ class FilecloudIo(Account): self.form_data = {} self.form_data['username'] = user - self.form_data['password'] = data['password'] + self.form_password = password html = self.load('https://secure.filecloud.io/user-login_p.html', post=self.form_data) if "you have successfully logged in" not in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FilefactoryCom.py b/module/plugins/accounts/FilefactoryCom.py index 980a39a11..ee90cfbdf 100644 --- a/module/plugins/accounts/FilefactoryCom.py +++ b/module/plugins/accounts/FilefactoryCom.py @@ -22,7 +22,7 @@ class FilefactoryCom(Account): VALID_UNTIL_PATTERN = r'Premium valid until: <strong>(?P<D>\d{1,2})\w{1,2} (?P<M>\w{3}), (?P<Y>\d{4})</strong>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.filefactory.com/account/") m = re.search(self.VALID_UNTIL_PATTERN, html) @@ -37,13 +37,13 @@ class FilefactoryCom(Account): return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} - def login(self, user, data, req): + def login(self, user, password, data, req): req.http.c.setopt(pycurl.REFERER, "http://www.filefactory.com/member/login.php") html = self.load("https://www.filefactory.com/member/signin.php", post={'loginEmail' : user, - 'loginPassword': data['password'], + 'loginPassword': password, 'Submit' : "Sign In"}) if req.lastEffectiveURL != "http://www.filefactory.com/account/": - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FilejungleCom.py b/module/plugins/accounts/FilejungleCom.py index 69fb37a65..5c91c3822 100644 --- a/module/plugins/accounts/FilejungleCom.py +++ b/module/plugins/accounts/FilejungleCom.py @@ -25,7 +25,7 @@ class FilejungleCom(Account): LOGIN_FAILED_PATTERN = r'<span htmlfor="loginUser(Name|Password)" generated="true" class="fail_info">' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load(self.URL + "dashboard.php") m = re.search(self.TRAFFIC_LEFT_PATTERN, html) if m: @@ -38,14 +38,14 @@ class FilejungleCom(Account): return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load(urlparse.urljoin(self.URL, "login.php"), post={'loginUserName' : user, - 'loginUserPassword' : data['password'], + 'loginUserPassword' : password, 'loginFormSubmit' : "Login", 'recaptcha_challenge_field' : "", 'recaptcha_response_field' : "", 'recaptcha_shortencode_field': ""}) if re.search(self.LOGIN_FAILED_PATTERN, html): - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FilerNet.py b/module/plugins/accounts/FilerNet.py index 186568841..c4d06690b 100644 --- a/module/plugins/accounts/FilerNet.py +++ b/module/plugins/accounts/FilerNet.py @@ -23,7 +23,7 @@ class FilerNet(Account): FREE_PATTERN = r'Account Status</th>\s*<td>\s*Free' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("https://filer.net/profile") #: Free user @@ -43,17 +43,17 @@ class FilerNet(Account): return {'premium': False, 'validuntil': None, 'trafficleft': None} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://filer.net/login") token = re.search(self.TOKEN_PATTERN, html).group(1) html = self.load("https://filer.net/login_check", post={'_username' : user, - '_password' : data['password'], + '_password' : password, '_remember_me': "on", '_csrf_token' : token, '_target_path': "https://filer.net/"}) if 'Logout' not in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FilesMailRu.py b/module/plugins/accounts/FilesMailRu.py index 50d00f990..a01de48fd 100644 --- a/module/plugins/accounts/FilesMailRu.py +++ b/module/plugins/accounts/FilesMailRu.py @@ -14,18 +14,18 @@ class FilesMailRu(Account): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): return {'validuntil': None, 'trafficleft': None} - def login(self, user, data, req): + def login(self, user, password, data, req): user, domain = user.split("@") html = self.load("https://swa.mail.ru/cgi-bin/auth", post={'Domain' : domain, 'Login' : user, - 'Password': data['password'], + 'Password': password, 'Page' : "http://files.mail.ru/"}) if "ÐевеÑМПе ÐžÐŒÑ Ð¿ÐŸÐ»ÑзПваÑÐµÐ»Ñ ÐžÐ»Ðž паÑПлÑ" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FileserveCom.py b/module/plugins/accounts/FileserveCom.py index 5bd129ab7..528bf7e58 100644 --- a/module/plugins/accounts/FileserveCom.py +++ b/module/plugins/accounts/FileserveCom.py @@ -17,12 +17,12 @@ class FileserveCom(Account): __authors__ = [("mkaay", "mkaay@mkaay.de")] - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) html = self.load("http://app.fileserve.com/api/login/", post={'username': user, - 'password': data['password'], + 'password': password, 'submit': "Submit+Query"}) res = json_loads(html) @@ -33,19 +33,19 @@ class FileserveCom(Account): return {'premium': False, 'trafficleft': None, 'validuntil': None} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://app.fileserve.com/api/login/", post={'username': user, - 'password': data['password'], + 'password': password, 'submit' : "Submit+Query"}) res = json_loads(html) if not res['type']: - self.wrong_password() + self.fail() #: Login at fileserv html self.load("http://www.fileserve.com/login.php", post={'loginUserName' : user, - 'loginUserPassword': data['password'], + 'loginUserPassword': password, 'autoLogin' : "checked", 'loginFormSubmit' : "Login"}) diff --git a/module/plugins/accounts/FourSharedCom.py b/module/plugins/accounts/FourSharedCom.py index 0084ffd57..448f0e185 100644 --- a/module/plugins/accounts/FourSharedCom.py +++ b/module/plugins/accounts/FourSharedCom.py @@ -15,20 +15,20 @@ class FourSharedCom(Account): ("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): #: Free mode only for now return {'premium': False} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("4shared.com", "4langcookie", "en") res = self.load("https://www.4shared.com/web/login", post={'login' : user, - 'password' : data['password'], + 'password' : password, 'remember' : "on", '_remember': "on", 'returnTo' : "http://www.4shared.com/account/home.jsp"}) if 'Please log in to access your 4shared account' in res: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FreakshareCom.py b/module/plugins/accounts/FreakshareCom.py index 46c70fe67..404e60ee1 100644 --- a/module/plugins/accounts/FreakshareCom.py +++ b/module/plugins/accounts/FreakshareCom.py @@ -17,7 +17,7 @@ class FreakshareCom(Account): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = None trafficleft = None @@ -41,13 +41,13 @@ class FreakshareCom(Account): return {'premium': premium, 'validuntil': validuntil, 'trafficleft': trafficleft} - def login(self, user, data, req): + def login(self, user, password, data, req): self.load("http://freakshare.com/index.php?language=EN") html = self.load("https://freakshare.com/login.html", post={'submit': "Login", 'user' : user, - 'pass' : data['password']}) + 'pass' : password}) if ">Wrong Username or Password" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/FreeWayMe.py b/module/plugins/accounts/FreeWayMe.py index b370439d0..bfb2747cb 100644 --- a/module/plugins/accounts/FreeWayMe.py +++ b/module/plugins/accounts/FreeWayMe.py @@ -15,7 +15,7 @@ class FreeWayMe(Account): __authors__ = [("Nicolas Giese", "james@free-way.me")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): status = self.get_account_status(user, req) self.log_debug(status) @@ -33,21 +33,21 @@ class FreeWayMe(Account): return account_info - def login(self, user, data, req): + def login(self, user, password, data, req): status = self.get_account_status(user, req) #: Check if user and password are valid if not status: - self.wrong_password() + self.fail() def get_account_status(self, user, req): answer = self.load("http://www.free-way.bz/ajax/jd.php", #@TODO: Revert to `https` in 0.4.10 - get={'id': 4, 'user': user, 'pass': self.get_account_data(user)['password']}) + get={'id': 4, 'user': user, 'pass': self.get_data(user)['password']}) self.log_debug("Login: %s" % answer) if answer == "Invalid login": - self.wrong_password() + self.fail() return json_loads(answer) diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py index 1e2cd5293..7d7359fd0 100644 --- a/module/plugins/accounts/FshareVn.py +++ b/module/plugins/accounts/FshareVn.py @@ -24,7 +24,7 @@ class FshareVn(Account): DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>KÃch hoạt download trá»±c tiếp</dt>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.fshare.vn/account_info.php") if re.search(self.LIFETIME_PATTERN, html): @@ -45,15 +45,15 @@ class FshareVn(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://www.fshare.vn/login.php", post={'LoginForm[email]' : user, - 'LoginForm[password]' : data['password'], + 'LoginForm[password]' : password, 'LoginForm[rememberMe]': 1, 'yt0' : "Login"}) if not re.search(r'<img\s+alt="VIP"', html): - self.wrong_password() + self.fail() def get_traffic_left(self): diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index 08030895a..7d65d0176 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -20,7 +20,7 @@ class HellshareCz(Account): CREDIT_LEFT_PATTERN = r'<div class="credit-link">\s*<table>\s*<tr>\s*<th>(\d+|\d\d\.\d\d\.)</th>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): self.relogin(user) html = self.load("http://www.hellshare.com/") @@ -52,7 +52,7 @@ class HellshareCz(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('http://www.hellshare.com/') if req.lastEffectiveURL != 'http://www.hellshare.com/': #: Switch to English @@ -72,9 +72,9 @@ class HellshareCz(Account): html = self.load("https://www.hellshare.com/login", get={'do': "loginForm-submit"}, post={'login' : "Log in", - 'password' : data['password'], + 'password' : password, 'username' : user, 'perm_login': "on"}) if "<p>You input a wrong user name or wrong password</p>" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/HighWayMe.py b/module/plugins/accounts/HighWayMe.py index 5f0d971ae..f546c2fe1 100644 --- a/module/plugins/accounts/HighWayMe.py +++ b/module/plugins/accounts/HighWayMe.py @@ -15,7 +15,7 @@ class HighWayMe(Account): __authors__ = [("EvolutionClip", "evolutionclip@live.de")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = -1 trafficleft = None @@ -40,11 +40,11 @@ class HighWayMe(Account): 'trafficleft': trafficleft} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://high-way.me/api.php?login", post={'login': '1', 'user': user, - 'pass': data['password']}) + 'pass': password}) if 'UserOrPassInvalid' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/Keep2ShareCc.py b/module/plugins/accounts/Keep2ShareCc.py index 097ae7c7e..3a6100bb3 100644 --- a/module/plugins/accounts/Keep2ShareCc.py +++ b/module/plugins/accounts/Keep2ShareCc.py @@ -24,7 +24,7 @@ class Keep2ShareCc(Account): LOGIN_FAIL_PATTERN = r'Please fix the following input errors' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = -1 premium = False @@ -60,14 +60,14 @@ class Keep2ShareCc(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("keep2share.cc", "lang", "en") html = self.load("https://keep2share.cc/login.html", post={'LoginForm[username]' : user, - 'LoginForm[password]' : data['password'], + 'LoginForm[password]' : password, 'LoginForm[rememberMe]': 1, 'yt0' : ""}) if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/LetitbitNet.py b/module/plugins/accounts/LetitbitNet.py index c4265761a..2d0e1b236 100644 --- a/module/plugins/accounts/LetitbitNet.py +++ b/module/plugins/accounts/LetitbitNet.py @@ -15,9 +15,9 @@ class LetitbitNet(Account): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): ## DISABLED BECAUSE IT GET 'key exausted' EVEN IF VALID ## - # api_key = self.get_account_data(user)['password'] + # api_key = self.get_data(user)['password'] # json_data = [api_key, ['key/info']] # api_rep = self.load("http://api.letitbit.net/json", # post={'r': json_dumps(json_data)}) @@ -31,6 +31,6 @@ class LetitbitNet(Account): return {'premium': True} - def login(self, user, data, req): + def login(self, user, password, data, req): #: API_KEY is the username and the PREMIUM_KEY is the password self.log_info(_("You must use your API KEY as username and the PREMIUM KEY as password")) diff --git a/module/plugins/accounts/LinksnappyCom.py b/module/plugins/accounts/LinksnappyCom.py index adad37148..9a90cd79d 100644 --- a/module/plugins/accounts/LinksnappyCom.py +++ b/module/plugins/accounts/LinksnappyCom.py @@ -17,12 +17,12 @@ class LinksnappyCom(Account): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) r = self.load('http://gen.linksnappy.com/lseAPI.php', get={'act' : 'USERDETAILS', 'username': user, - 'password': hashlib.md5(data['password']).hexdigest()}) + 'password': hashlib.md5(password).hexdigest()}) self.log_debug("JSON data: " + r) @@ -52,11 +52,11 @@ class LinksnappyCom(Account): 'trafficleft': trafficleft} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://gen.linksnappy.com/lseAPI.php", get={'act' : 'USERDETAILS', 'username': user, - 'password': hashlib.md5(data['password']).hexdigest()}) + 'password': hashlib.md5(password).hexdigest()}) if "Invalid Account Details" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/MegaDebridEu.py b/module/plugins/accounts/MegaDebridEu.py index 5fe490ec4..682de4db1 100644 --- a/module/plugins/accounts/MegaDebridEu.py +++ b/module/plugins/accounts/MegaDebridEu.py @@ -19,12 +19,12 @@ class MegaDebridEu(Account): API_URL = "https://www.mega-debrid.eu/api.php" - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) jsonResponse = self.load(self.API_URL, get={'action' : 'connectUser', 'login' : user, - 'password': data['password']}) + 'password': password}) res = json_loads(jsonResponse) if res['response_code'] == "ok": @@ -34,11 +34,11 @@ class MegaDebridEu(Account): return {'status': False, 'premium': False} - def login(self, user, data, req): + def login(self, user, password, data, req): jsonResponse = self.load(self.API_URL, get={'action' : 'connectUser', 'login' : user, - 'password': data['password']}) + 'password': password}) res = json_loads(jsonResponse) if res['response_code'] != "ok": - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/MegaRapidCz.py b/module/plugins/accounts/MegaRapidCz.py index a0b0f4702..ce2d78994 100644 --- a/module/plugins/accounts/MegaRapidCz.py +++ b/module/plugins/accounts/MegaRapidCz.py @@ -25,12 +25,12 @@ class MegaRapidCz(Account): TRAFFIC_LEFT_PATTERN = r'<tr><td>Kredit</td><td>(.*?) GiB' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): htmll = self.load("http://megarapid.cz/mujucet/") m = re.search(self.LIMITDL_PATTERN, htmll) if m: - data = self.get_account_data(user) + data = self.get_data(user) data['options']['limitDL'] = [int(m.group(1))] m = re.search(self.VALID_UNTIL_PATTERN, htmll) @@ -46,7 +46,7 @@ class MegaRapidCz(Account): return {'premium': False, 'trafficleft': None, 'validuntil': None} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://megarapid.cz/prihlaseni/") if "Heslo:" in html: @@ -56,6 +56,6 @@ class MegaRapidCz(Account): html = self.load("https://megarapid.cz/prihlaseni/", post={'hash' : hashes, 'login' : user, - 'pass1' : data['password'], + 'pass1' : password, 'remember': 1, 'sbmt' : u"PÅihlásit"}) diff --git a/module/plugins/accounts/MegaRapidoNet.py b/module/plugins/accounts/MegaRapidoNet.py index cc2bb5c06..d07df500c 100644 --- a/module/plugins/accounts/MegaRapidoNet.py +++ b/module/plugins/accounts/MegaRapidoNet.py @@ -21,7 +21,7 @@ class MegaRapidoNet(Account): USER_ID_PATTERN = r'<\s*?div[^>]*?class\s*?=\s*?["\']checkbox_compartilhar["\'].*?>.*?<\s*?input[^>]*?name\s*?=\s*?["\']usar["\'].*?>.*?<\s*?input[^>]*?name\s*?=\s*?["\']user["\'][^>]*?value\s*?=\s*?["\'](.*?)\s*?["\']' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = None premium = False @@ -40,16 +40,16 @@ class MegaRapidoNet(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, data, req): self.load("http://megarapido.net/login") self.load("http://megarapido.net/painel_user/ajax/logar.php", post={'login': user, - 'senha': data['password']}) + 'senha': password}) html = self.load("http://megarapido.net/gerador") if "sair" not in html.lower(): - self.wrong_password() + self.fail() else: m = re.search(self.USER_ID_PATTERN, html) if m: diff --git a/module/plugins/accounts/MegasharesCom.py b/module/plugins/accounts/MegasharesCom.py index 51c410e1c..ef6724512 100644 --- a/module/plugins/accounts/MegasharesCom.py +++ b/module/plugins/accounts/MegasharesCom.py @@ -20,7 +20,7 @@ class MegasharesCom(Account): VALID_UNTIL_PATTERN = r'<p class="premium_info_box">Period Ends: (\w{3} \d{1,2}, \d{4})</p>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): # self.relogin(user) html = self.load("http://d01.megashares.com/myms.php") @@ -37,12 +37,12 @@ class MegasharesCom(Account): return {'validuntil': validuntil, 'trafficleft': -1, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('http://d01.megashares.com/myms_login.php', post={'httpref' : "", 'myms_login' : "Login", 'mymslogin_name': user, - 'mymspassword' : data['password']}) + 'mymspassword' : password}) if not '<span class="b ml">%s</span>' % user in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/MultishareCz.py b/module/plugins/accounts/MultishareCz.py index db8170b47..2bcbae8f8 100644 --- a/module/plugins/accounts/MultishareCz.py +++ b/module/plugins/accounts/MultishareCz.py @@ -20,7 +20,7 @@ class MultishareCz(Account): ACCOUNT_INFO_PATTERN = r'<input type="hidden" id="(u_ID|u_hash)" name=".+?" value="(.+?)">' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): # self.relogin(user) html = self.load("http://www.multishare.cz/profil/") @@ -34,11 +34,11 @@ class MultishareCz(Account): return dict(mms_info, **{'validuntil': -1, 'trafficleft': trafficleft}) - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('https://www.multishare.cz/html/prihlaseni_process.php', post={'akce' : "PÅihlásit", - 'heslo': data['password'], + 'heslo': password, 'jmeno': user}) if '<div class="akce-chyba akce">' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/MyfastfileCom.py b/module/plugins/accounts/MyfastfileCom.py index 200c61b81..d049b13e6 100644 --- a/module/plugins/accounts/MyfastfileCom.py +++ b/module/plugins/accounts/MyfastfileCom.py @@ -17,7 +17,7 @@ class MyfastfileCom(Account): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): if 'days_left' in self.json_data: validuntil = time.time() + self.json_data['days_left'] * 24 * 60 * 60 return {'premium': True, 'validuntil': validuntil, 'trafficleft': -1} @@ -25,15 +25,15 @@ class MyfastfileCom(Account): self.log_error(_("Unable to get account information")) - def login(self, user, data, req): + def login(self, user, password, data, req): #: Password to use is the API-Password written in http://myfastfile.com/myaccount html = self.load("https://myfastfile.com/api.php", get={'user': user, - 'pass': data['password']}) + 'pass': password}) self.log_debug("JSON data: " + html) self.json_data = json_loads(html) if self.json_data['status'] != 'ok': self.log_error(_('Invalid login. The password to use is the API-Password you find in your "My Account" page')) - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/NitroflareCom.py b/module/plugins/accounts/NitroflareCom.py index 5ee434006..f4e9d402a 100644 --- a/module/plugins/accounts/NitroflareCom.py +++ b/module/plugins/accounts/NitroflareCom.py @@ -24,7 +24,7 @@ class NitroflareCom(Account): TOKEN_PATTERN = r'name="token" value="(.+?)"' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = -1 trafficleft = None premium = False @@ -67,7 +67,7 @@ class NitroflareCom(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://nitroflare.com/login") token = re.search(self.TOKEN_PATTERN, html).group(1) @@ -75,8 +75,8 @@ class NitroflareCom(Account): html = self.load("https://nitroflare.com/login", post={'login' : "", 'email' : user, - 'password': data['password'], + 'password': password, 'token' : token}) if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py index 088d9df69..dfd10c6f7 100644 --- a/module/plugins/accounts/NoPremiumPl.py +++ b/module/plugins/accounts/NoPremiumPl.py @@ -32,7 +32,7 @@ class NoPremiumPl(Account): _pwd = None - def load_account_info(self, name, req): + def parse_info(self, name, req): self._req = req try: result = json_loads(self.run_auth_query()) @@ -54,18 +54,18 @@ class NoPremiumPl(Account): 'premium' : premium } - def login(self, user, data, req): + def login(self, user, password, data, req): self._usr = user - self._pwd = hashlib.sha1(hashlib.md5(data['password']).hexdigest()).hexdigest() + self._pwd = hashlib.sha1(hashlib.md5(password).hexdigest()).hexdigest() self._req = req try: response = json_loads(self.run_auth_query()) except Exception: - self.wrong_password() + self.fail() if "errno" in response.keys(): - self.wrong_password() + self.fail() data['usr'] = self._usr data['pwd'] = self._pwd diff --git a/module/plugins/accounts/NowVideoSx.py b/module/plugins/accounts/NowVideoSx.py index bb64a2e62..8d4add5f6 100644 --- a/module/plugins/accounts/NowVideoSx.py +++ b/module/plugins/accounts/NowVideoSx.py @@ -20,7 +20,7 @@ class NowVideoSx(Account): VALID_UNTIL_PATTERN = r'>Your premium membership expires on: (.+?)<' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = -1 premium = None @@ -48,10 +48,10 @@ class NowVideoSx(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://www.nowvideo.sx/login.php", post={'user': user, - 'pass': data['password']}) + 'pass': password}) if re.search(r'>Log In<', html): - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/OboomCom.py b/module/plugins/accounts/OboomCom.py index 09e8f8c62..5dc1fcae2 100644 --- a/module/plugins/accounts/OboomCom.py +++ b/module/plugins/accounts/OboomCom.py @@ -32,7 +32,7 @@ class OboomCom(Account): def load_account_data(self, user, req): - passwd = self.get_account_data(user)['password'] + passwd = self.get_data(user)['password'] salt = passwd[::-1] pbkdf2 = PBKDF2(passwd, salt, 1000).hexread(16) @@ -42,12 +42,12 @@ class OboomCom(Account): if not result[0] == 200: self.log_warning(_("Failed to log in: %s") % result[1]) - self.wrong_password() + self.fail() return result[1] - def load_account_info(self, name, req): + def parse_info(self, name, req): account_data = self.load_account_data(name, req) userData = account_data['user'] @@ -76,5 +76,5 @@ class OboomCom(Account): 'session' : session} - def login(self, user, data, req): + def login(self, user, password, data, req): self.load_account_data(user, req) diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py index fa44f050c..2553462ca 100644 --- a/module/plugins/accounts/OneFichierCom.py +++ b/module/plugins/accounts/OneFichierCom.py @@ -22,7 +22,7 @@ class OneFichierCom(Account): VALID_UNTIL_PATTERN = r'Your Premium Status will end the (\d+/\d+/\d+)' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = -1 premium = None @@ -44,15 +44,15 @@ class OneFichierCom(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} - def login(self, user, data, req): + def login(self, user, password, data, req): req.http.c.setopt(pycurl.REFERER, "https://1fichier.com/login.pl?lg=en") html = self.load("https://1fichier.com/login.pl?lg=en", post={'mail' : user, - 'pass' : data['password'], + 'pass' : password, 'It' : "on", 'purge' : "off", 'valider': "Send"}) if '>Invalid email address' in html or '>Invalid password' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/OverLoadMe.py b/module/plugins/accounts/OverLoadMe.py index 664b6543f..5e7625244 100644 --- a/module/plugins/accounts/OverLoadMe.py +++ b/module/plugins/accounts/OverLoadMe.py @@ -15,11 +15,11 @@ class OverLoadMe(Account): __authors__ = [("marley", "marley@over-load.me")] - def load_account_info(self, user, req): - data = self.get_account_data(user) + def parse_info(self, user, password, data, req): + data = self.get_data(user) html = self.load("https://api.over-load.me/account.php", get={'user': user, - 'auth': data['password']}).strip() + 'auth': password}).strip() data = json_loads(html) self.log_debug(data) @@ -31,12 +31,12 @@ class OverLoadMe(Account): return {'premium': True, 'validuntil': data['expirationunix'], 'trafficleft': -1} - def login(self, user, data, req): + def login(self, user, password, data, req): jsondata = self.load("https://api.over-load.me/account.php", get={'user': user, - 'auth': data['password']}).strip() + 'auth': password}).strip() data = json_loads(jsondata) if data['err'] == 1: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/PremiumTo.py b/module/plugins/accounts/PremiumTo.py index 248a2aa3c..e25b3b33e 100644 --- a/module/plugins/accounts/PremiumTo.py +++ b/module/plugins/accounts/PremiumTo.py @@ -16,7 +16,7 @@ class PremiumTo(Account): ("stickell", "l.stickell@yahoo.it")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): traffic = self.load("http://premium.to/api/straffic.php", #@TODO: Revert to `https` in 0.4.10 get={'username': self.username, 'password': self.password}) @@ -28,12 +28,12 @@ class PremiumTo(Account): return {'premium': False, 'trafficleft': None, 'validuntil': None} - def login(self, user, data, req): + def login(self, user, password, data, req): self.username = user - self.password = data['password'] + self.password = password authcode = self.load("http://premium.to/api/getauthcode.php", #@TODO: Revert to `https` in 0.4.10 get={'username': user, 'password': self.password}) if "wrong username" in authcode: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/PremiumizeMe.py b/module/plugins/accounts/PremiumizeMe.py index f2b304b69..11a2c648f 100644 --- a/module/plugins/accounts/PremiumizeMe.py +++ b/module/plugins/accounts/PremiumizeMe.py @@ -15,7 +15,7 @@ class PremiumizeMe(Account): __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): #: Get user data from premiumize.me status = self.get_account_status(user, req) self.log_debug(status) @@ -30,13 +30,13 @@ class PremiumizeMe(Account): return account_info - def login(self, user, data, req): + def login(self, user, password, data, req): #: Get user data from premiumize.me status = self.get_account_status(user, req) #: Check if user and password are valid if status['status'] != 200: - self.wrong_password() + self.fail() def get_account_status(self, user, req): @@ -45,5 +45,5 @@ class PremiumizeMe(Account): answer = self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 get={'method' : "accountstatus", 'params[login]': user, - 'params[pass]' : self.get_account_data(user)['password']}) + 'params[pass]' : self.get_data(user)['password']}) return json_loads(answer) diff --git a/module/plugins/accounts/QuickshareCz.py b/module/plugins/accounts/QuickshareCz.py index 2cb33136f..b1416d967 100644 --- a/module/plugins/accounts/QuickshareCz.py +++ b/module/plugins/accounts/QuickshareCz.py @@ -19,7 +19,7 @@ class QuickshareCz(Account): TRAFFIC_LEFT_PATTERN = r'Stav kreditu: <strong>(.+?)</strong>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.quickshare.cz/premium") m = re.search(self.TRAFFIC_LEFT_PATTERN, html) @@ -33,11 +33,11 @@ class QuickshareCz(Account): return {'validuntil': -1, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load('http://www.quickshare.cz/html/prihlaseni_process.php', post={'akce' : u'PÅihlásit', - 'heslo': data['password'], + 'heslo': password, 'jmeno': user}) if u'>TakovÃœ uÅŸivatel neexistuje.<' in html or u'>Å patné heslo.<' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/RPNetBiz.py b/module/plugins/accounts/RPNetBiz.py index c746d75a4..cd1523a92 100644 --- a/module/plugins/accounts/RPNetBiz.py +++ b/module/plugins/accounts/RPNetBiz.py @@ -15,7 +15,7 @@ class RPNetBiz(Account): __authors__ = [("Dman", "dmanugm@gmail.com")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): #: Get account information from rpnet.biz res = self.get_account_status(user, req) try: @@ -33,19 +33,19 @@ class RPNetBiz(Account): return account_info - def login(self, user, data, req): + def login(self, user, password, data, req): #: Get account information from rpnet.biz res = self.get_account_status(user, req) #: If we have an error in the res, we have wrong login information if 'error' in res: - self.wrong_password() + self.fail() def get_account_status(self, user, req): #: Using the rpnet API, check if valid premium account res = self.load("https://premium.rpnet.biz/client_api.php", - get={'username': user, 'password': self.get_account_data(user)['password'], + get={'username': user, 'password': self.get_data(user)['password'], 'action': "showAccountInformation"}) self.log_debug("JSON data: %s" % res) diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 30b7029ed..6e2c0a134 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -32,7 +32,7 @@ class RapideoPl(Account): _pwd = None - def load_account_info(self, name, req): + def parse_info(self, name, req): self._req = req try: result = json_loads(self.run_auth_query()) @@ -54,18 +54,18 @@ class RapideoPl(Account): 'premium' : premium } - def login(self, user, data, req): + def login(self, user, password, data, req): self._usr = user - self._pwd = hashlib.md5(data['password']).hexdigest() + self._pwd = hashlib.md5(password).hexdigest() self._req = req try: response = json_loads(self.run_auth_query()) except Exception: - self.wrong_password() + self.fail() if "errno" in response.keys(): - self.wrong_password() + self.fail() data['usr'] = self._usr data['pwd'] = self._pwd diff --git a/module/plugins/accounts/RapidgatorNet.py b/module/plugins/accounts/RapidgatorNet.py index 06cdca23e..56f3aa866 100644 --- a/module/plugins/accounts/RapidgatorNet.py +++ b/module/plugins/accounts/RapidgatorNet.py @@ -20,14 +20,14 @@ class RapidgatorNet(Account): API_URL = "http://rapidgator.net/api/user" - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = None premium = False sid = None try: - sid = self.get_account_data(user).get('sid', None) + sid = self.get_data(user).get('sid', None) assert sid html = self.load(urlparse.urljoin(self.API_URL, "info"), @@ -56,11 +56,11 @@ class RapidgatorNet(Account): 'sid' : sid} - def login(self, user, data, req): + def login(self, user, password, data, req): try: html = self.load(urlparse.urljoin(self.API_URL, "login"), post={'username': user, - 'password': data['password']}) + 'password': password}) self.log_debug("API:LOGIN", html) @@ -75,4 +75,4 @@ class RapidgatorNet(Account): except Exception, e: self.log_error(e) - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/RapiduNet.py b/module/plugins/accounts/RapiduNet.py index 738aca14f..29c939602 100644 --- a/module/plugins/accounts/RapiduNet.py +++ b/module/plugins/accounts/RapiduNet.py @@ -26,7 +26,7 @@ class RapiduNet(Account): TRAFFIC_LEFT_PATTERN = r'class="tipsyS"><b>(.+?)<' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = -1 premium = False @@ -47,7 +47,7 @@ class RapiduNet(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): self.load("https://rapidu.net/ajax.php", get={'a': "getChangeLang"}, post={'_go' : "", @@ -57,10 +57,10 @@ class RapiduNet(Account): get={'a': "getUserLogin"}, post={'_go' : "", 'login' : user, - 'pass' : data['password'], + 'pass' : password, 'remember': "1"})) self.log_debug(json) if not json['message'] == "success": - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/RealdebridCom.py b/module/plugins/accounts/RealdebridCom.py index 69ec6668b..c39293ce6 100644 --- a/module/plugins/accounts/RealdebridCom.py +++ b/module/plugins/accounts/RealdebridCom.py @@ -16,7 +16,7 @@ class RealdebridCom(Account): __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): if self.pin_code: return @@ -30,15 +30,15 @@ class RealdebridCom(Account): 'premium' : True } - def login(self, user, data, req): + def login(self, user, password, data, req): self.pin_code = False html = self.load("https://real-debrid.com/ajax/login.php", get={'user': user, - 'pass': data['password']}) + 'pass': password}) if "Your login informations are incorrect" in html: - self.wrong_password() + self.fail() elif "PIN Code required" in html: self.log_warning(_("PIN code required. Please login to https://real-debrid.com using the PIN or disable the double authentication in your control panel on https://real-debrid.com")) diff --git a/module/plugins/accounts/RehostTo.py b/module/plugins/accounts/RehostTo.py index 80e8af6a1..1bfd79088 100644 --- a/module/plugins/accounts/RehostTo.py +++ b/module/plugins/accounts/RehostTo.py @@ -14,7 +14,7 @@ class RehostTo(Account): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False trafficleft = None validuntil = -1 @@ -22,7 +22,7 @@ class RehostTo(Account): html = self.load("https://rehost.to/api.php", get={'cmd' : "login", 'user': user, - 'pass': self.get_account_data(user)['password']}) + 'pass': self.get_data(user)['password']}) try: session = html.split(",")[1].split("=")[1] @@ -46,12 +46,12 @@ class RehostTo(Account): 'session' : session} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://rehost.to/api.php", get={'cmd': "login", 'user': user, - 'pass': data['password']}) + 'pass': password}) if "ERROR" in html: self.log_debug(html) - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/ShareonlineBiz.py b/module/plugins/accounts/ShareonlineBiz.py index 180838d82..85cdfecd9 100644 --- a/module/plugins/accounts/ShareonlineBiz.py +++ b/module/plugins/accounts/ShareonlineBiz.py @@ -21,10 +21,10 @@ class ShareonlineBiz(Account): get={'q' : "userdetails", 'aux' : "traffic", 'username': user, - 'password': self.get_account_data(user)['password']}) + 'password': self.get_data(user)['password']}) - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = None trafficleft = -1 @@ -61,9 +61,9 @@ class ShareonlineBiz(Account): 'maxtraffic' : maxtraffic} - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.api_response(user, req) err = re.search(r'\*\*(.+?)\*\*', html) if err: self.log_error(err.group(1).strip()) - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/SimplyPremiumCom.py b/module/plugins/accounts/SimplyPremiumCom.py index 1486578a3..534a75be8 100644 --- a/module/plugins/accounts/SimplyPremiumCom.py +++ b/module/plugins/accounts/SimplyPremiumCom.py @@ -15,7 +15,7 @@ class SimplyPremiumCom(Account): __authors__ = [("EvolutionClip", "evolutionclip@live.de")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium = False validuntil = -1 trafficleft = None @@ -38,11 +38,11 @@ class SimplyPremiumCom(Account): return {'premium': premium, 'validuntil': validuntil, 'trafficleft': trafficleft} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("simply-premium.com", "lang", "EN") html = self.load("https://www.simply-premium.com/login.php", - post={'key': user} if not data['password'] else {'login_name': user, 'login_pass': data['password']}) + post={'key': user} if not password else {'login_name': user, 'login_pass': password}) if 'logout' not in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/SimplydebridCom.py b/module/plugins/accounts/SimplydebridCom.py index 1707efe22..b123021dd 100644 --- a/module/plugins/accounts/SimplydebridCom.py +++ b/module/plugins/accounts/SimplydebridCom.py @@ -16,7 +16,7 @@ class SimplydebridCom(Account): __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): get_data = {'login': 2, 'u': self.loginname, 'p': self.password} res = self.load("http://simply-debrid.com/api.php", get=get_data) data = [x.strip() for x in res.split(";")] @@ -26,11 +26,11 @@ class SimplydebridCom(Account): return {'trafficleft': -1, 'validuntil': time.mktime(time.strptime(str(data[2]), "%d/%m/%Y"))} - def login(self, user, data, req): + def login(self, user, password, data, req): self.loginname = user - self.password = data['password'] + self.password = password get_data = {'login': 1, 'u': self.loginname, 'p': self.password} res = self.load("https://simply-debrid.com/api.php", get=get_data) if res != "02: loggin success": - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index f3f33eff6..2201e4294 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -34,7 +34,7 @@ class SmoozedCom(Account): __authors__ = [("", "")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): status = self.get_account_status(user, req) self.log_debug(status) @@ -61,17 +61,17 @@ class SmoozedCom(Account): return info - def login(self, user, data, req): + def login(self, user, password, data, req): #: Get user data from premiumize.me status = self.get_account_status(user, req) #: Check if user and password are valid if status['state'] != 'ok': - self.wrong_password() + self.fail() def get_account_status(self, user, req): - password = self.get_account_data(user)['password'] + password = self.get_data(user)['password'] salt = hashlib.sha256(password).hexdigest() encrypted = PBKDF2(password, salt, iterations=1000).hexread(32) diff --git a/module/plugins/accounts/TurbobitNet.py b/module/plugins/accounts/TurbobitNet.py index a1280f5bf..afed6efbc 100644 --- a/module/plugins/accounts/TurbobitNet.py +++ b/module/plugins/accounts/TurbobitNet.py @@ -17,7 +17,7 @@ class TurbobitNet(Account): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://turbobit.net") m = re.search(r'<u>Turbo Access</u> to ([\d.]+)', html) @@ -31,13 +31,13 @@ class TurbobitNet(Account): return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} - def login(self, user, data, req): + def login(self, user, password, data, req): req.cj.setCookie("turbobit.net", "user_lang", "en") html = self.load("http://turbobit.net/user/login", post={"user[login]" : user, - "user[pass]" : data['password'], + "user[pass]" : password, "user[submit]": "Login"}) if not '<div class="menu-item user-name">' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/UlozTo.py b/module/plugins/accounts/UlozTo.py index 6f3cfe225..ed4c11a23 100644 --- a/module/plugins/accounts/UlozTo.py +++ b/module/plugins/accounts/UlozTo.py @@ -21,7 +21,7 @@ class UlozTo(Account): TRAFFIC_LEFT_PATTERN = r'<li class="menu-kredit"><a .*?title=".+?GB = ([\d.]+) MB"' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.ulozto.net/") m = re.search(self.TRAFFIC_LEFT_PATTERN, html) @@ -32,7 +32,7 @@ class UlozTo(Account): return {'validuntil': -1, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): login_page = self.load('http://www.ulozto.net/?do=web-login') action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') token = re.search('_token_" value="(.+?)"', login_page).group(1) @@ -41,9 +41,9 @@ class UlozTo(Account): post={'_token_' : token, 'do' : "loginForm-submit", 'login' : u"PÅihlásit", - 'password': data['password'], + 'password': password, 'username': user, 'remember': "on"}) if '<div class="flash error">' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/UploadableCh.py b/module/plugins/accounts/UploadableCh.py index aeb3a241d..e1865bb52 100644 --- a/module/plugins/accounts/UploadableCh.py +++ b/module/plugins/accounts/UploadableCh.py @@ -14,7 +14,7 @@ class UploadableCh(Account): __authors__ = [("Sasch", "gsasch@gmail.com")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("http://www.uploadable.ch/login.php") premium = '<a href="/logout.php"' in html @@ -23,12 +23,12 @@ class UploadableCh(Account): return {'validuntil': None, 'trafficleft': trafficleft, 'premium': premium} #@TODO: validuntil - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://www.uploadable.ch/login.php", post={'userName' : user, - 'userPassword' : data['password'], + 'userPassword' : password, 'autoLogin' : "1", 'action__login': "normalLogin"}) if "Login failed" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py index a59394e7f..407658354 100644 --- a/module/plugins/accounts/UploadedTo.py +++ b/module/plugins/accounts/UploadedTo.py @@ -22,7 +22,7 @@ class UploadedTo(Account): TRAFFIC_LEFT_PATTERN = r'<b class="cB">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = None premium = None @@ -61,13 +61,13 @@ class UploadedTo(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, data, req): #: req.cj.setCookie("uploaded.net", "lang", "en") html = self.load("https://uploaded.net/io/login", post={'id': user, - 'pw': data['password'], + 'pw': password, '_': ""}) if '"err"' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/UploadheroCom.py b/module/plugins/accounts/UploadheroCom.py index e9bad9273..0b82f0e5a 100644 --- a/module/plugins/accounts/UploadheroCom.py +++ b/module/plugins/accounts/UploadheroCom.py @@ -18,10 +18,10 @@ class UploadheroCom(Account): __authors__ = [("mcmyst", "mcmyst@hotmail.fr")] - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): premium_pattern = re.compile('Il vous reste <span class="bleu">(\d+)</span> jours premium') - data = self.get_account_data(user) + data = self.get_data(user) html = self.load("http://uploadhero.co/my-account") if premium_pattern.search(html): @@ -34,10 +34,10 @@ class UploadheroCom(Account): return account_info - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("http://uploadhero.co/lib/connexion.php", post={'pseudo_login': user, - 'password_login': data['password']}) + 'password_login': password}) if "mot de passe invalide" in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/UploadingCom.py b/module/plugins/accounts/UploadingCom.py index d0c497d21..d269abde7 100644 --- a/module/plugins/accounts/UploadingCom.py +++ b/module/plugins/accounts/UploadingCom.py @@ -22,7 +22,7 @@ class UploadingCom(Account): VALID_UNTIL_PATTERN = r'Valid Until:(.+?)<' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = None premium = None @@ -54,7 +54,7 @@ class UploadingCom(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, data, req): set_cookies(req.cj, [("uploading.com", "lang" , "1" ), ("uploading.com", "language", "1" ), @@ -64,5 +64,5 @@ class UploadingCom(Account): self.load("http://uploading.com/") self.load("https://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time.time() * 1000), post={'email' : user, - 'password': data['password'], + 'password': password, 'remember': "on"}) diff --git a/module/plugins/accounts/WebshareCz.py b/module/plugins/accounts/WebshareCz.py index 7d0da3cbd..1f2adb7f5 100644 --- a/module/plugins/accounts/WebshareCz.py +++ b/module/plugins/accounts/WebshareCz.py @@ -25,9 +25,9 @@ class WebshareCz(Account): TRAFFIC_LEFT_PATTERN = r'<bytes>(.+)</bytes>' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): html = self.load("https://webshare.cz/api/user_data/", - post={'wst': self.get_account_data(user).get('wst', None)}) + post={'wst': self.get_data(user).get('wst', None)}) self.log_debug("Response: " + html) @@ -41,16 +41,16 @@ class WebshareCz(Account): return {'validuntil': validuntil, 'trafficleft': -1, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): salt = self.load("https://webshare.cz/api/salt/", post={'username_or_email': user, 'wst' : ""}) if "<status>OK</status>" not in salt: - self.wrong_password() + self.fail() salt = re.search('<salt>(.+)</salt>', salt).group(1) - password = hashlib.sha1(md5_crypt.encrypt(data['password'], salt=salt)).hexdigest() + password = hashlib.sha1(md5_crypt.encrypt(password, salt=salt)).hexdigest() digest = hashlib.md5(user + ":Webshare:" + password).hexdigest() login = self.load("https://webshare.cz/api/login/", @@ -61,6 +61,6 @@ class WebshareCz(Account): 'wst' : ""}) if "<status>OK</status>" not in login: - self.wrong_password() + self.fail() data['wst'] = re.search('<token>(.+)</token>', login).group(1) diff --git a/module/plugins/accounts/XFileSharingPro.py b/module/plugins/accounts/XFileSharingPro.py index 514dc2bbe..62270a2b0 100644 --- a/module/plugins/accounts/XFileSharingPro.py +++ b/module/plugins/accounts/XFileSharingPro.py @@ -22,11 +22,7 @@ class XFileSharingPro(XFSAccount): return super(XFileSharingPro, self).init() - def load_account_info(self, user, req): - return super(XFileSharingPro if self.HOSTER_DOMAIN else XFSAccount, self).load_account_info(user, req) - - - def login(self, user, data, req): + def login(self, user, password, data, req): if self.HOSTER_DOMAIN: try: return super(XFileSharingPro, self).login(user, data, req) diff --git a/module/plugins/accounts/YibaishiwuCom.py b/module/plugins/accounts/YibaishiwuCom.py index 78e67d4ea..a1886c945 100644 --- a/module/plugins/accounts/YibaishiwuCom.py +++ b/module/plugins/accounts/YibaishiwuCom.py @@ -19,7 +19,7 @@ class YibaishiwuCom(Account): ACCOUNT_INFO_PATTERN = r'var USER_PERMISSION = {(.*?)}' - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): # self.relogin(user) html = self.load("http://115.com/") @@ -29,12 +29,12 @@ class YibaishiwuCom(Account): return dict({'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium}) - def login(self, user, data, req): + def login(self, user, password, data, req): html = self.load("https://passport.115.com/?ac=login", post={'back' : "http://www.115.com/", 'goto' : "http://115.com/", "login[account]": user, - "login[passwd]" : data['password']}) + "login[passwd]" : password}) if not 'var USER_PERMISSION = {' in html: - self.wrong_password() + self.fail() diff --git a/module/plugins/accounts/ZeveraCom.py b/module/plugins/accounts/ZeveraCom.py index fa4aed8e3..c7c958834 100644 --- a/module/plugins/accounts/ZeveraCom.py +++ b/module/plugins/accounts/ZeveraCom.py @@ -33,7 +33,7 @@ class ZeveraCom(Account): self.API_URL = "http://api.%s/jDownloader.ashx" % (self.HOSTER_DOMAIN or "") - def load_account_info(self, user, req): + def parse_info(self, user, password, data, req): validuntil = None trafficleft = None premium = False @@ -48,12 +48,12 @@ class ZeveraCom(Account): return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - def login(self, user, data, req): + def login(self, user, password, data, req): self.user = user - self.password = data['password'] + self.password = password if self.api_response(req) == "No trafic": - self.wrong_password() + self.fail() def api_response(self, req, just_header=False, **kwargs): diff --git a/module/plugins/crypter/XFileSharingProFolder.py b/module/plugins/crypter/XFileSharingProFolder.py index 12335515e..c81123b7e 100644 --- a/module/plugins/crypter/XFileSharingProFolder.py +++ b/module/plugins/crypter/XFileSharingProFolder.py @@ -43,8 +43,8 @@ class XFileSharingProFolder(XFSCrypter): else: return - self.user, data = self.account.select_account() - self.req = self.account.get_account_request(self.user) + self.user, data = self.account.select() + self.req = self.account.get_request(self.user) self.premium = self.account.is_premium(self.user) diff --git a/module/plugins/hooks/EasybytezComHook.py b/module/plugins/hooks/EasybytezComHook.py index f96668245..9e33bbad0 100644 --- a/module/plugins/hooks/EasybytezComHook.py +++ b/module/plugins/hooks/EasybytezComHook.py @@ -22,9 +22,9 @@ class EasybytezComHook(MultiHook): def get_hosters(self): - user, data = self.account.select_account() + user, data = self.account.select() html = self.load("http://www.easybytez.com", - req=self.account.get_account_request(user)) + req=self.account.get_request(user)) return re.search(r'</textarea>\s*Supported sites:(.*)', html).group(1).split(',') diff --git a/module/plugins/hooks/FreeWayMeHook.py b/module/plugins/hooks/FreeWayMeHook.py index 8defeeb3c..5f30d70fc 100644 --- a/module/plugins/hooks/FreeWayMeHook.py +++ b/module/plugins/hooks/FreeWayMeHook.py @@ -20,6 +20,6 @@ class FreeWayMeHook(MultiHook): def get_hosters(self): - user, data = self.account.select_account() + user, data = self.account.select() hostis = self.load("http://www.free-way.bz/ajax/jd.php", get={'id': 3, 'user': user, 'pass': data['password']}).replace("\"", "") #@TODO: Revert to `https` in 0.4.10 return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/PremiumToHook.py b/module/plugins/hooks/PremiumToHook.py index 6e940c5d9..062113e96 100644 --- a/module/plugins/hooks/PremiumToHook.py +++ b/module/plugins/hooks/PremiumToHook.py @@ -22,7 +22,7 @@ class PremiumToHook(MultiHook): def get_hosters(self): - user, data = self.account.select_account() + user, data = self.account.select() html = self.load("http://premium.to/api/hosters.php", get={'username': user, 'password': data['password']}) return [x.strip() for x in html.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/PremiumizeMeHook.py b/module/plugins/hooks/PremiumizeMeHook.py index c33b5e0a5..6be32b70b 100644 --- a/module/plugins/hooks/PremiumizeMeHook.py +++ b/module/plugins/hooks/PremiumizeMeHook.py @@ -22,7 +22,7 @@ class PremiumizeMeHook(MultiHook): def get_hosters(self): #: Get account data - user, data = self.account.select_account() + user, data = self.account.select() #: Get supported hosters list from premiumize.me using the #: json API v1 (see https://secure.premiumize.me/?show=api) diff --git a/module/plugins/hooks/RPNetBizHook.py b/module/plugins/hooks/RPNetBizHook.py index 2804c9356..5e7174de6 100644 --- a/module/plugins/hooks/RPNetBizHook.py +++ b/module/plugins/hooks/RPNetBizHook.py @@ -22,7 +22,7 @@ class RPNetBizHook(MultiHook): def get_hosters(self): #: Get account data - user, data = self.account.select_account() + user, data = self.account.select() res = self.load("https://premium.rpnet.biz/client_api.php", get={'username': user, 'password': data['password'], 'action': "showHosterList"}) diff --git a/module/plugins/hooks/RehostToHook.py b/module/plugins/hooks/RehostToHook.py index b3e37369c..58367e241 100644 --- a/module/plugins/hooks/RehostToHook.py +++ b/module/plugins/hooks/RehostToHook.py @@ -20,8 +20,8 @@ class RehostToHook(MultiHook): def get_hosters(self): - user, data = self.account.select_account() + user, data = self.account.select() html = self.load("http://rehost.to/api.php", get={'cmd' : "get_supported_och_dl", - 'long_ses': self.account.get_account_info(user)['session']}) + 'long_ses': self.account.get_data(user)['session']}) return [x.strip() for x in html.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/SmoozedComHook.py b/module/plugins/hooks/SmoozedComHook.py index a794934de..6b9b688ff 100644 --- a/module/plugins/hooks/SmoozedComHook.py +++ b/module/plugins/hooks/SmoozedComHook.py @@ -20,5 +20,5 @@ class SmoozedComHook(MultiHook): def get_hosters(self): - user, data = self.account.select_account() - return self.account.get_account_info(user)['hosters'] + user, data = self.account.select() + return self.account.get_data(user)['hosters'] diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index dd7490365..c8fb1f3db 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -67,12 +67,12 @@ class BasePlugin(Hoster): self.log_debug("Auth required", "Received HTTP status code: %d" % e.code) account = self.pyload.accountManager.getAccountPlugin('Http') - servers = [x['login'] for x in account.get_all_accounts()] + servers = [x['login'] for x in account.getAllAccounts()] #@TODO: Recheck in 0.4.10 server = urlparse.urlparse(pyfile.url).netloc if server in servers: self.log_debug("Logging on to %s" % server) - self.req.addAuth(account.get_account_data(server)['password']) + self.req.addAuth(account.get_data(server)['password']) else: pwd = self.get_password() if ':' in pwd: diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 77f86932a..0019cf3c2 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -27,7 +27,7 @@ class FastixRu(MultiHoster): def handle_premium(self, pyfile): - api_key = self.account.get_account_data(self.user) + api_key = self.account.get_data(self.user) api_key = api_key['api'] self.html = self.load("http://fastix.ru/api_v2/", diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index 7d828f706..21654fee3 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -111,7 +111,7 @@ class FilecloudIo(SimpleHoster): def handle_premium(self, pyfile): - akey = self.account.get_account_data(self.user)['akey'] + akey = self.account.get_data(self.user)['akey'] ukey = self.info['pattern']['ID'] self.log_debug("Akey: %s | Ukey: %s" % (akey, ukey)) rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 13680dec0..6cc42cb4b 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -187,7 +187,7 @@ class FileserveCom(Hoster): #: Try api download res = self.load("http://app.fileserve.com/api/download/premium/", post={'username': self.user, - 'password': self.account.get_account_data(self.user)['password'], + 'password': self.account.get_data(self.user)['password'], 'shorten': self.file_id}) if res: res = json_loads(res) diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py index e8917c88d..430562ce9 100644 --- a/module/plugins/hoster/FreeWayMe.py +++ b/module/plugins/hoster/FreeWayMe.py @@ -25,7 +25,7 @@ class FreeWayMe(MultiHoster): def handle_premium(self, pyfile): - user, data = self.account.select_account() + user, data = self.account.select() for _i in xrange(5): #: Try it five times @@ -33,7 +33,7 @@ class FreeWayMe(MultiHoster): get={'multiget': 7, 'url' : pyfile.url, 'user' : user, - 'pw' : self.account.get_account_data(user)['password'], + 'pw' : self.account.get_data(user)['password'], 'json' : ""}, just_header=True) diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index b431198d5..99185338f 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -39,11 +39,11 @@ class Ftp(Hoster): pass if not "@" in netloc: - servers = [x['login'] for x in self.account.get_all_accounts()] if self.account else [] + servers = [x['login'] for x in self.account.getAllAccounts()] if self.account else [] if netloc in servers: self.log_debug("Logging on to %s" % netloc) - self.req.addAuth(self.account.get_account_info(netloc)['password']) + self.req.addAuth(self.account.get_data(netloc)['password']) else: pwd = self.get_password() if ':' in pwd: diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 03314548c..b3aaa892e 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -124,7 +124,7 @@ class LetitbitNet(SimpleHoster): def handle_premium(self, pyfile): api_key = self.user - premium_key = self.account.get_account_data(self.user)['password'] + premium_key = self.account.get_data(self.user)['password'] json_data = [api_key, ["download/direct_links", {'pass': premium_key, 'link': pyfile.url}]] api_rep = self.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py index 5490d9e71..817978542 100644 --- a/module/plugins/hoster/LinksnappyCom.py +++ b/module/plugins/hoster/LinksnappyCom.py @@ -30,7 +30,7 @@ class LinksnappyCom(MultiHoster): json_params = json_dumps({'link' : pyfile.url, 'type' : host, 'username': self.user, - 'password': self.account.get_account_data(self.user)['password']}) + 'password': self.account.get_data(self.user)['password']}) r = self.load("http://gen.linksnappy.com/genAPI.php", post={'genLinks': json_params}) diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index 631fe18ca..9049f0cd9 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -30,7 +30,7 @@ class MegaDebridEu(MultiHoster): Connexion to the mega-debrid API Return True if succeed """ - user, data = self.account.select_account() + user, data = self.account.select() jsonResponse = self.load(self.API_URL, get={'action': 'connectUser', 'login': user, 'password': data['password']}) res = json_loads(jsonResponse) diff --git a/module/plugins/hoster/MegaRapidoNet.py b/module/plugins/hoster/MegaRapidoNet.py index 29917d27f..6676a565d 100644 --- a/module/plugins/hoster/MegaRapidoNet.py +++ b/module/plugins/hoster/MegaRapidoNet.py @@ -47,7 +47,7 @@ class MegaRapidoNet(MultiHoster): 'links' : pyfile.url, 'exibir' : "normal", 'usar' : "premium", - 'user' : self.account.get_account_info(self.user).get('sid', None), + 'user' : self.account.get_data(self.user).get('sid', None), 'autoreset': ""}) if "desloga e loga novamente para gerar seus links" in self.html.lower(): diff --git a/module/plugins/hoster/MyfastfileCom.py b/module/plugins/hoster/MyfastfileCom.py index 346010b0c..f855cd5bf 100644 --- a/module/plugins/hoster/MyfastfileCom.py +++ b/module/plugins/hoster/MyfastfileCom.py @@ -27,7 +27,7 @@ class MyfastfileCom(MultiHoster): def handle_premium(self, pyfile): self.html = self.load('http://myfastfile.com/api.php', - get={'user': self.user, 'pass': self.account.get_account_data(self.user)['password'], + get={'user': self.user, 'pass': self.account.get_data(self.user)['password'], 'link': pyfile.url}) self.log_debug("JSON data: " + self.html) diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py index 8b66fd5f2..9e2a5a93c 100644 --- a/module/plugins/hoster/NoPremiumPl.py +++ b/module/plugins/hoster/NoPremiumPl.py @@ -39,7 +39,7 @@ class NoPremiumPl(MultiHoster): def prepare(self): super(NoPremiumPl, self).prepare() - data = self.account.get_account_data(self.user) + data = self.account.get_data(self.user) self.usr = data['usr'] self.pwd = data['pwd'] diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index 68e593dd4..480febf61 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -58,7 +58,7 @@ class OboomCom(Hoster): def get_session_token(self): if self.premium: - accountInfo = self.account.get_account_info(self.user, True) + accountInfo = self.account.get_data(self.user, True) if "session" in accountInfo: self.session_token = accountInfo['session'] else: diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index 1ae24fcc3..0b5bab6a5 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -28,7 +28,7 @@ class OverLoadMe(MultiHoster): def handle_premium(self, pyfile): - data = self.account.get_account_data(self.user) + data = self.account.get_data(self.user) page = self.load("https://api.over-load.me/getdownload.php", get={'auth': data['password'], 'link': pyfile.url}) diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index 6442b09b9..fb00bb84f 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -31,7 +31,7 @@ class PremiumizeMe(MultiHoster): pyfile.name = ".".join(temp) #: Get account data - user, data = self.account.select_account() + user, data = self.account.select() #: Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) data = json_loads(self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index c7c90d01c..785d2b6c4 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -26,7 +26,7 @@ class RPNetBiz(MultiHoster): def handle_premium(self, pyfile): - user, data = self.account.select_account() + user, data = self.account.select() #: Get the download link res = self.load("https://premium.rpnet.biz/client_api.php", diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index e2cc6e467..e1a0d278f 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -39,7 +39,7 @@ class RapideoPl(MultiHoster): def prepare(self): super(RapideoPl, self).prepare() - data = self.account.get_account_data(self.user) + data = self.account.get_data(self.user) self.usr = data['usr'] self.pwd = data['pwd'] diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 354d69acb..636ea1bcc 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -51,7 +51,7 @@ class RapidgatorNet(SimpleHoster): def setup(self): if self.account: - self.sid = self.account.get_account_info(self.user).get('sid', None) + self.sid = self.account.get_data(self.user).get('sid', None) else: self.sid = None diff --git a/module/plugins/hoster/RehostTo.py b/module/plugins/hoster/RehostTo.py index 954c246dc..6f0645e9f 100644 --- a/module/plugins/hoster/RehostTo.py +++ b/module/plugins/hoster/RehostTo.py @@ -23,7 +23,7 @@ class RehostTo(MultiHoster): def handle_premium(self, pyfile): self.download("http://rehost.to/process_download.php", get={'user': "cookie", - 'pass': self.account.get_account_info(self.user)['session'], + 'pass': self.account.get_data(self.user)['session'], 'dl' : pyfile.url}, disposition=True) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index bdbaa1e6f..c26b893bf 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -124,7 +124,7 @@ class ShareonlineBiz(SimpleHoster): def handle_premium(self, pyfile): #: Should be working better loading (account) api internally html = self.load("http://api.share-online.biz/account.php", get={'username': self.user, - 'password': self.account.get_account_data(self.user)['password'], + 'password': self.account.get_data(self.user)['password'], 'act' : "download", 'lid' : self.info['fileid']}) diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index 7b52be2be..33d098a00 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -36,7 +36,7 @@ class SmoozedCom(MultiHoster): pyfile.name = ".".join(temp) #: Check the link - get_data = {'session_key': self.account.get_account_info(self.user)['session'], + get_data = {'session_key': self.account.get_data(self.user)['session'], 'url' : pyfile.url} data = json_loads(self.load("http://www2.smoozed.com/api/check", get=get_data)) diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index 6ea038751..0a89363f8 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -41,7 +41,7 @@ class WebshareCz(SimpleHoster): def handle_free(self, pyfile): - wst = self.account.get_account_data(self.user).get('wst', None) if self.account else None + wst = self.account.get_data(self.user).get('wst', None) if self.account else None api_data = get_url("https://webshare.cz/api/file_link/", post={'ident': self.info['pattern']['ID'], 'wst': wst}) diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index bd629d51e..d7caf3097 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -44,8 +44,8 @@ class XFileSharingPro(XFSHoster): else: return - self.user, data = self.account.select_account() - self.req = self.account.get_account_request(self.user) + self.user, data = self.account.select() + self.req = self.account.get_request(self.user) self.premium = self.account.is_premium(self.user) diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py index 03521a0ea..3a3fd4768 100644 --- a/module/plugins/internal/Account.py +++ b/module/plugins/internal/Account.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- +from __future__ import with_statement + import random -import threading import time import traceback @@ -9,10 +10,6 @@ from module.plugins.internal.Plugin import Plugin from module.utils import compare_time, lock, parseFileSize as parse_size -class WrongPassword(Exception): - pass - - class Account(Plugin): __name__ = "Account" __type__ = "account" @@ -21,25 +18,20 @@ class Account(Plugin): __description__ = """Base account plugin""" __license__ = "GPLv3" - __authors__ = [("mkaay", "mkaay@mkaay.de")] + __authors__ = [("mkaay" , "mkaay@mkaay.de" ), + ("Walter Purcaro", "vuolter@gmail.com")] + + + LOGIN_TIMEOUT = 10 * 60 #: After that time (in minutes) pyload will relogin the account + INFO_THRESHOLD = 10 * 60 #: After that time (in minutes) account data will be reloaded def __init__(self, manager, accounts): self.pyload = manager.core self.info = {} #: Provide information in dict here - self.manager = manager - self.accounts = {} - self.infos = {} #: Cache for account information - self.lock = threading.RLock() - self.timestamps = {} - - self.login_timeout = 10 * 60 #: After that time (in minutes) pyload will relogin the account - self.info_threshold = 10 * 60 #: After that time (in minutes) account data will be reloaded - self.init() - - self.set_accounts(accounts) + self.init_accounts(accounts) def init(self): @@ -49,240 +41,239 @@ class Account(Plugin): pass - def login(self, user, data, req): + def login(self, user, password, data, req): """ Login into account, the cookies will be saved so user can be recognized - - :param user: loginname - :param data: data dictionary - :param req: `Request` instance """ pass @lock - def _login(self, user, data): - #: Set timestamp for login - self.timestamps[user] = time.time() - - self.req = self.get_account_request(user) + def _login(self, user): try: - self.login(user, data, self.req) + info = self.info[user] + info['login']['timestamp'] = time.time() #: Set timestamp for login - except WrongPassword: - self.log_warning( - _("Could not login with account %(user)s | %(msg)s") % {'user': user, - 'msg': _("Wrong Password")}) - success = data['valid'] = False + self.req = self.get_request(user) + self.login(user, info['login']['password'], info['data'], self.req) except Exception, e: self.log_warning( _("Could not login with account %(user)s | %(msg)s") % {'user': user, - 'msg': e}) - success = data['valid'] = False + 'msg' : e}) + res = info['login']['valid'] = False if self.pyload.debug: traceback.print_exc() else: - success = True + res = True finally: - if hasattr(self, "req"): - if self.req: - self.req.close() - del self.req - return success + if self.req: + self.req.close() + del self.req + + return res def relogin(self, user): - req = self.get_account_request(user) - if req: + with self.get_request(user) as req: req.clearCookies() - req.close() - if user in self.infos: - del self.infos[user] #: Delete old information + if user in self.info: + self.info[user]['login'].clear() - return self._login(user, self.accounts[user]) + return self._login(user) - def set_accounts(self, accounts): - self.accounts = accounts - for user, data in self.accounts.iteritems(): - self._login(user, data) - self.infos[user] = {} + def init_accounts(self, accounts): + for user, data in accounts.iteritems(): + self.add(user, data['password'], data['options']) + self._login(user) - def update_accounts(self, user, password=None, options={}): + def add(self, user, password=None, options): + if user not in self.info: + self.info[user] = {'login': {'valid': True, 'password': password or "", 'timestamp': 0}, #@NOTE: Do not remove `'valid': True` in 0.4.9 or accounts will not login + 'data' : {'options': options, 'timestamp': 0}} + self._login(user) + return True + else: + self.log_error(_("Error adding account"), _("User already exists")) + + + def update(self, user, password=None, options): """ Updates account and return true if anything changed """ - if user in self.accounts: - self.accounts[user]['valid'] = True #: Do not remove or accounts will not login + if user not in self.info: + return self.add(user, password, options) + + elif password or options: if password: - self.accounts[user]['password'] = password + self.info[user]['login']['password'] = password self.relogin(user) return True + if options: - before = self.accounts[user]['options'] - self.accounts[user]['options'].update(options) - return self.accounts[user]['options'] is not before - else: - self.accounts[user] = {'password': password, 'options': options, 'valid': True} - self._login(user, self.accounts[user]) - return True + before = self.info[user]['data'][user]['options'] + self.info[user]['data']['options'].update(options) + return self.info[user]['data']['options'] != before - #: Deprecated method, use `update_accounts` instead + #: Deprecated method, use `update` instead (Remove in 0.4.10) def updateAccounts(self, *args, **kwargs): - return self.update_accounts(*args, **kwargs) + return self.update(*args, **kwargs) + + def remove(self, user=None): # -> def remove + if not user: + self.info.clear() - def remove_account(self, user): - if user in self.accounts: - del self.accounts[user] - if user in self.infos: - del self.infos[user] - if user in self.timestamps: - del self.timestamps[user] + elif user in self.info: + del self.info[user] - #: Deprecated method, use `remove_account` instead + #: Deprecated method, use `remove` instead (Remove in 0.4.10) def removeAccount(self, *args, **kwargs): - return self.remove_account(*args, **kwargs) + return self.remove(*args, **kwargs) + + + def get_data(self, user, reload=False): + return self.get_info(user, reload)['data'] @lock - def get_account_info(self, name, force=False): + def get_info(self, user, reload=False): """ Retrieve account infos for an user, do **not** overwrite this method!\\ - just use it to retrieve infos in hoster plugins. see `load_account_info` + just use it to retrieve infos in hoster plugins. see `load_info` - :param name: username - :param force: reloads cached account information + :param user: username + :param reload: reloads cached account information :return: dictionary with information """ - data = Account.load_account_info(self, name) + if not reload and user in self.info: + info = self.info[user] - if force or name not in self.infos: - self.log_debug("Get Account Info for %s" % name) - self.req = self.get_account_request(name) + if info['data']['timestamp'] + self.INFO_THRESHOLD * 60 < time.time(): + self.log_debug("Reached timeout for account data") + self.schedule_refresh(user) - try: - infos = self.load_account_info(name, self.req) - if not type(infos) is dict: - raise Exception("Wrong return format") + else: + self.log_debug("Get Account Info for: %s" % user) + info = self.load_info(user) - except Exception, e: - infos = super(self.__class__, self).load_account_info(name, self.req) - infos['error'] = str(e) + self.log_debug("Account Info: %s" % info) + return info - if self.pyload.debug: - traceback.print_exc() - finally: - if hasattr(self, "req"): - if self.req: - self.req.close() - del self.req + def is_premium(self, user): + return self.get_info(user)['premium'] - self.log_debug("Account Info: %s" % infos) - infos['timestamp'] = time.time() - self.infos[name] = infos + def load_info(self, user): + self.log_critical(user in self.info) ############################# - elif "timestamp" in self.infos[name] and self.infos[name]['timestamp'] + self.info_threshold * 60 < time.time(): - self.log_debug("Reached timeout for account data") - self.schedule_refresh(name) + info = self.info[user] + data = info['data'] - data.update(self.infos[name]) - return data + #@TODO: Remove in 0.4.10 + data.update({'login': user, + 'type' : self.__name__}, + 'valid': self.info[user]['login']['valid']) + try: + self.req = self.get_request(user) + extra_info = self.parse_info(user, info['login']['password'], info, req) - def is_premium(self, user): - info = self.get_account_info(user) - return info['premium'] + if extra_info and isinstance(extra_info, dict): + data.update(extra_info) + data['timestamp'] = time.time() + except Exception, e: + self.log_warning(_("Error loading info for account %(user)s | %(err)s") % + {'user': user, 'err': e}) + data['error'] = str(e) - def load_account_info(self, name, req=None): + if self.pyload.debug: + traceback.print_exc(): + + else: + for key in ('premium', 'validuntil', 'trafficleft', 'maxtraffic'): + if key not in data: + data[key] = None + + finally: + if self.req: + self.req.close() + del self.req + + self.info[user].update(info) + return info + + + def parse_info(self, user, password, info, req): """ This should be overwritten in account plugin and retrieving account information for user - :param name: + :param user: :param req: `Request` instance :return: """ - return {'validuntil' : None, #: -1 for unlimited - 'login' : name, - # 'password' : self.accounts[name]['password'], #: Commented due security reason - 'options' : self.accounts[name]['options'], - 'valid' : self.accounts[name]['valid'], - 'trafficleft': None, #: In bytes, -1 for unlimited - 'maxtraffic' : None, - 'premium' : None, - 'timestamp' : 0, #: Time this info was retrieved - 'type' : self.__name__} - - - def get_all_accounts(self, force=False): - return [self.get_account_info(user, force) for user, data in self.accounts.iteritems()] + pass - #: Deprecated method, use `get_all_accounts` instead + #: Remove in 0.4.10 def getAllAccounts(self, *args, **kwargs): - return self.get_all_accounts(*args, **kwargs) + return [self.get_data(user, reload) for user, info in self.info.iteritems()] - def get_account_request(self, user=None): + def get_request(self, user=None): if not user: - user, data = self.select_account() + user, info = self.select() return self.pyload.requestFactory.getRequest(self.__name__, user) - def get_account_cookies(self, user=None): - if not user: - user, data = self.select_account() + def get_cookies(self, user=None): if not user: + user, info = self.select() return None - cj = self.pyload.requestFactory.getCookieJar(self.__name__, user) - return cj - + return self.pyload.requestFactory.getCookieJar(self.__name__, user) - def get_account_data(self, user): - return self.accounts[user] - - def select_account(self): + #@TODO: Random account only? Simply crazy... rewrite + def select(self): """ Returns an valid account name and data """ usable = [] - for user, data in self.accounts.iteritems(): - if not data['valid']: + for user, info in self.info.iteritems(): + if not info['login']['valid']: continue - if "time" in data['options'] and data['options']['time']: + options = info['data']['options'] + if "time" in options and options['time']: time_data = "" try: - time_data = data['options']['time'][0] + time_data = options['time'][0] start, end = time_data.split("-") if not compare_time(start.split(":"), end.split(":")): continue + except Exception: - self.log_warning(_("Your Time %s has wrong format, use 1:22-3:44") % time_data) + self.log_warning(_("Your time %s has wrong format, use 1:22-3:44") % time_data) - if user in self.infos: - if "validuntil" in self.infos[user]: - if self.infos[user]['validuntil'] > 0 and time.time() > self.infos[user]['validuntil']: - continue - if "trafficleft" in self.infos[user]: - if self.infos[user]['trafficleft'] == 0: - continue + if user in self.info: + if None is not self.info[user]['validuntil'] > 0 and time.time() > self.info[user]['validuntil']: + continue + if None is not self.info[user]['trafficleft'] == 0: + continue - usable.append((user, data)) + usable.append((user, info)) if not usable: return None, None @@ -291,44 +282,45 @@ class Account(Plugin): def can_use(self): - return self.select_account() is not (None, None) + return self.select() is not (None, None) def parse_traffic(self, value, unit=None): #: Return kilobytes if not unit and not isinstance(value, basestring): unit = "KB" - return parse_size(value, unit) - - def wrong_password(self): - raise WrongPassword + return parse_size(value, unit) def empty(self, user): - if user in self.infos: - self.log_warning(_("Account %s has not enough traffic, checking again in 30min") % user) + if user not in self.info: + return + + self.log_warning(_("Account %s has not enough traffic, checking again in 30min") % user) - self.infos[user].update({'trafficleft': 0}) - self.schedule_refresh(user, 30 * 60) + self.info[user]['data'].update({'trafficleft': 0}) + self.schedule_refresh(user, 30 * 60) def expired(self, user): - if user in self.infos: - self.log_warning(_("Account %s is expired, checking again in 1h") % user) + if user not in self.info: + return + + self.log_warning(_("Account %s is expired, checking again in 1h") % user) - self.infos[user].update({'validuntil': time.time() - 1}) - self.schedule_refresh(user, 60 * 60) + self.info[user]['data'].update({'validuntil': time.time() - 1}) + self.schedule_refresh(user, 60 * 60) - def schedule_refresh(self, user, time=0, force=True): + def schedule_refresh(self, user, time=0, reload=True): """ Add task to refresh account info to sheduler """ self.log_debug("Scheduled Account refresh for %s in %s seconds." % (user, time)) - self.pyload.scheduler.addJob(time, self.get_account_info, [user, force]) + self.pyload.scheduler.addJob(time, self.get_info, [user, reload]) - #: Deprecated method, use `schedule_refresh` instead + #: Deprecated method, use `schedule_refresh` instead (Remove in 0.4.10) def scheduleRefresh(self, *args, **kwargs): return self.schedule_refresh(*args, **kwargs) @@ -338,8 +330,8 @@ class Account(Plugin): """ Checks if user is still logged in """ - if user in self.timestamps: - if self.login_timeout > 0 and self.timestamps[user] + self.login_timeout * 60 < time.time(): + if user in self.info: + if self.LOGIN_TIMEOUT > 0 and self.info[user]['login']['timestamp'] + self.LOGIN_TIMEOUT * 60 < time.time(): self.log_debug("Reached login timeout for %s" % user) return self.relogin(user) else: diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py index 23512d7c4..16aab6188 100644 --- a/module/plugins/internal/Addon.py +++ b/module/plugins/internal/Addon.py @@ -71,7 +71,7 @@ class Addon(Plugin): self.event_map = None if self.event_list: - self.log_debug("Deprecated method `event_list`, use `event_map` instead") + self.log_debug("Deprecated method `event_list`, use `event_map` instead") (Remove in 0.4.10) for f in self.event_list: self.manager.addEvent(f, getattr(self, f)) @@ -83,7 +83,7 @@ class Addon(Plugin): self.cb = self.pyload.scheduler.addJob(max(0, delay), self._periodical, [threaded], threaded=threaded) - #: Deprecated method, use `init_periodical` instead + #: Deprecated method, use `init_periodical` instead (Remove in 0.4.10) def initPeriodical(self, *args, **kwargs): return self.init_periodical(*args, **kwargs) @@ -119,7 +119,7 @@ class Addon(Plugin): return self.get_config("activated") - #: Deprecated method, use `is_activated` instead + #: Deprecated method, use `is_activated` instead (Remove in 0.4.10) def isActivated(self, *args, **kwargs): return self.is_activated(*args, **kwargs) @@ -131,7 +131,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `deactivate` instead + #: Deprecated method, use `deactivate` instead (Remove in 0.4.10) def unload(self, *args, **kwargs): return self.deactivate(*args, **kwargs) @@ -143,7 +143,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `activate` instead + #: Deprecated method, use `activate` instead (Remove in 0.4.10) def coreReady(self, *args, **kwargs): return self.activate(*args, **kwargs) @@ -155,7 +155,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `exit` instead + #: Deprecated method, use `exit` instead (Remove in 0.4.10) def coreExiting(self, *args, **kwargs): return self.exit(*args, **kwargs) @@ -164,7 +164,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `download_preparing` instead + #: Deprecated method, use `download_preparing` instead (Remove in 0.4.10) def downloadPreparing(self, *args, **kwargs): return self.download_preparing(*args, **kwargs) @@ -173,7 +173,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `download_finished` instead + #: Deprecated method, use `download_finished` instead (Remove in 0.4.10) def downloadFinished(self, *args, **kwargs): return self.download_finished(*args, **kwargs) @@ -182,7 +182,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `download_failed` instead + #: Deprecated method, use `download_failed` instead (Remove in 0.4.10) def downloadFailed(self, *args, **kwargs): return self.download_failed(*args, **kwargs) @@ -191,7 +191,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `package_finished` instead + #: Deprecated method, use `package_finished` instead (Remove in 0.4.10) def packageFinished(self, *args, **kwargs): return self.package_finished(*args, **kwargs) @@ -200,7 +200,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `before_reconnect` instead + #: Deprecated method, use `before_reconnect` instead (Remove in 0.4.10) def beforeReconnecting(self, *args, **kwargs): return self.before_reconnect(*args, **kwargs) @@ -209,7 +209,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `after_reconnect` instead + #: Deprecated method, use `after_reconnect` instead (Remove in 0.4.10) def afterReconnecting(self, ip): return self.after_reconnect(ip, None) @@ -221,7 +221,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `captcha_task` instead + #: Deprecated method, use `captcha_task` instead (Remove in 0.4.10) def newCaptchaTask(self, *args, **kwargs): return self.captcha_task(*args, **kwargs) @@ -230,7 +230,7 @@ class Addon(Plugin): pass - #: Deprecated method, use `captcha_correct` instead + #: Deprecated method, use `captcha_correct` instead (Remove in 0.4.10) def captchaCorrect(self, *args, **kwargs): return self.captcha_correct(*args, **kwargs) @@ -239,6 +239,6 @@ class Addon(Plugin): pass - #: Deprecated method, use `captcha_invalid` instead + #: Deprecated method, use `captcha_invalid` instead (Remove in 0.4.10) def captchaInvalid(self, *args, **kwargs): return self.captcha_invalid(*args, **kwargs) diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 971158a36..d3eef43c8 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -3,8 +3,8 @@ from module.plugins.internal.Plugin import Plugin -class Captcha(Plugin): - __name__ = "Captcha" +class CaptchaService(Plugin): + __name__ = "CaptchaService" __type__ = "captcha" __version__ = "0.31" __status__ = "testing" diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py index cc732247e..c0135fb1f 100644 --- a/module/plugins/internal/Container.py +++ b/module/plugins/internal/Container.py @@ -39,7 +39,7 @@ class Container(Crypter): self._create_packages() - #: Deprecated method, use `_load2disk` instead + #: Deprecated method, use `_load2disk` instead (Remove in 0.4.10) def loadToDisk(self, *args, **kwargs): return self._load2disk(*args, **kwargs) @@ -68,7 +68,7 @@ class Container(Crypter): self.fail(_("File not exists")) - #: Deprecated method, use `delete_tmp` instead + #: Deprecated method, use `delete_tmp` instead (Remove in 0.4.10) def deleteTmp(self, *args, **kwargs): return self.delete_tmp(*args, **kwargs) diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index 0d2e4dcc4..1d2728bd3 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -96,10 +96,10 @@ class Hoster(Plugin): self.account = None if self.account: - self.user, data = self.account.select_account() + self.user, data = self.account.select() #: Browser instance, see `network.Browser` - self.req = self.account.get_account_request(self.user) + self.req = self.account.get_request(self.user) self.chunk_limit = -1 #: Chunk limit, -1 for unlimited #: Enables resume (will be ignored if server dont accept chunks) @@ -593,7 +593,7 @@ class Hoster(Plugin): if not self.account: return True - traffic = self.account.get_account_info(self.user, True)['trafficleft'] + traffic = self.account.get_data(self.user, True)['trafficleft'] if traffic is None: return False @@ -612,7 +612,7 @@ class Hoster(Plugin): return self.pyfile.package().password or "" - #: Deprecated method, use `check_for_same_files` instead + #: Deprecated method, use `check_for_same_files` instead (Remove in 0.4.10) def checkForSameFiles(self, *args, **kwargs): return self.check_for_same_files(*args, **kwargs) diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index f5cfa289d..308ba2966 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -57,8 +57,8 @@ class SimpleCrypter(Crypter, SimpleHoster): account = self.pyload.accountManager.getAccountPlugin(account_name) if account and account.can_use(): - self.user, data = account.select_account() - self.req = account.get_account_request(self.user) + self.user, data = account.select() + self.req = account.get_request(self.user) self.premium = account.is_premium(self.user) self.account = account diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 5ba207934..4a293b703 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -101,7 +101,7 @@ class SimpleHoster(Hoster): ('Html file' , r'\A\s*<!DOCTYPE html' )] CHECK_FILE = True #: Set to False to not check the last downloaded file with declared error patterns - CHECK_TRAFFIC = False #: Set to True to force checking traffic left for premium account + CHECK_TRAFFIC = False #: Set to True to reload checking traffic left for premium account COOKIES = True #: or False or list of tuples [(domain, name, value)] DIRECT_LINK = None #: Set to True to looking for direct link (as defined in handle_direct method), set to None to do it if self.account is True else False DISPOSITION = True #: Set to True to use any content-disposition value in http header as file name @@ -499,7 +499,7 @@ class SimpleHoster(Hoster): self.check_status(getinfo=False) - #: Deprecated method + #: Deprecated method (Remove in 0.4.10) def get_fileInfo(self): self.info = {} self.check_info() diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index 8612bad63..7df169ee9 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -53,7 +53,7 @@ class XFSAccount(Account): set_cookies(req.cj, self.COOKIES) - def load_account_info(self, user, req): + def parse_info(self, user, req): validuntil = None trafficleft = None leechtraffic = None @@ -150,7 +150,7 @@ class XFSAccount(Account): 'premium' : premium} - def login(self, user, data, req): + def login(self, user, password, info, req): if not self.HOSTER_URL: #@TODO: Remove in 0.4.10 raise Exception(_("Missing HOSTER_DOMAIN")) @@ -174,4 +174,4 @@ class XFSAccount(Account): html = self.load(url, post=inputs) if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrong_password() + self.fail() |