From 6c0b4518828b230ded4ab91e4f79b56f48ef50c6 Mon Sep 17 00:00:00 2001 From: Noam Date: Thu, 18 May 2017 17:02:53 +0300 Subject: [PATCH 1/3] rutracker optional session cookie --- data/interfaces/default/config.html | 4 ++++ headphones/config.py | 1 + headphones/rutracker.py | 5 ++++- headphones/webserve.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 841df0d1..02f40718 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -649,6 +649,10 @@ +
+ + +
diff --git a/headphones/config.py b/headphones/config.py index 57af4c16..98b23785 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -248,6 +248,7 @@ _CONFIG_DEFINITIONS = { 'RUTRACKER_PASSWORD': (str, 'Rutracker', ''), 'RUTRACKER_RATIO': (str, 'Rutracker', ''), 'RUTRACKER_USER': (str, 'Rutracker', ''), + 'RUTRACKER_COOKIE': (str, 'Rutracker', ''), 'SAB_APIKEY': (str, 'SABnzbd', ''), 'SAB_CATEGORY': (str, 'SABnzbd', ''), 'SAB_HOST': (str, 'SABnzbd', ''), diff --git a/headphones/rutracker.py b/headphones/rutracker.py index 658d490e..7d094906 100644 --- a/headphones/rutracker.py +++ b/headphones/rutracker.py @@ -49,7 +49,10 @@ class Rutracker(object): # try again if not self.has_bb_session_cookie(r): time.sleep(10) - r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False) + if headphones.CONFIG.RUTRACKER_COOKIE: + r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False, cookies={'bb_session':headphones.CONFIG.RUTRACKER_COOKIE}) + else: + r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False) if self.has_bb_session_cookie(r): self.loggedin = True logger.info("Successfully logged in to rutracker") diff --git a/headphones/webserve.py b/headphones/webserve.py index 2b0f2699..ee353fe2 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1240,6 +1240,7 @@ class WebInterface(object): "rutracker_user": headphones.CONFIG.RUTRACKER_USER, "rutracker_password": headphones.CONFIG.RUTRACKER_PASSWORD, "rutracker_ratio": headphones.CONFIG.RUTRACKER_RATIO, + "rutracker_cookie": headphones.CONFIG.RUTRACKER_COOKIE, "use_apollo": checked(headphones.CONFIG.APOLLO), "apollo_username": headphones.CONFIG.APOLLO_USERNAME, "apollo_password": headphones.CONFIG.APOLLO_PASSWORD, From ecadf8cdabdd01820edebb01e4e5045fab832744 Mon Sep 17 00:00:00 2001 From: Noam Date: Thu, 18 May 2017 18:26:16 +0300 Subject: [PATCH 2/3] log cookie attempt --- headphones/rutracker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/headphones/rutracker.py b/headphones/rutracker.py index 7d094906..1c689504 100644 --- a/headphones/rutracker.py +++ b/headphones/rutracker.py @@ -50,6 +50,7 @@ class Rutracker(object): if not self.has_bb_session_cookie(r): time.sleep(10) if headphones.CONFIG.RUTRACKER_COOKIE: + logger.info("Attempting to log in using predefined cookie...") r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False, cookies={'bb_session':headphones.CONFIG.RUTRACKER_COOKIE}) else: r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False) From 3110659633de1d3cada334bf4714f24b1c0b781c Mon Sep 17 00:00:00 2001 From: Noam Date: Thu, 18 May 2017 18:28:01 +0300 Subject: [PATCH 3/3] travis space --- headphones/rutracker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/rutracker.py b/headphones/rutracker.py index 1c689504..7d18ca1e 100644 --- a/headphones/rutracker.py +++ b/headphones/rutracker.py @@ -51,7 +51,7 @@ class Rutracker(object): time.sleep(10) if headphones.CONFIG.RUTRACKER_COOKIE: logger.info("Attempting to log in using predefined cookie...") - r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False, cookies={'bb_session':headphones.CONFIG.RUTRACKER_COOKIE}) + r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False, cookies={'bb_session': headphones.CONFIG.RUTRACKER_COOKIE}) else: r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False) if self.has_bb_session_cookie(r):