mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 16:34:01 +01:00
Allow the use of apikey with GazelleAPI & Redacted
This commit is contained in:
@@ -708,6 +708,10 @@
|
|||||||
<input id="use_redacted" type="checkbox" class="bigcheck" name="use_redacted" value="1" ${config['use_redacted']} /><label for="use_redacted"><span class="option">Redacted</span></label>
|
<input id="use_redacted" type="checkbox" class="bigcheck" name="use_redacted" value="1" ${config['use_redacted']} /><label for="use_redacted"><span class="option">Redacted</span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="config">
|
<div class="config">
|
||||||
|
<div class="row">
|
||||||
|
<label>Api Key</label>
|
||||||
|
<input type="text" name="redacted_apikey" value="${config['redacted_apikey']}" size="36">
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label>Username</label>
|
<label>Username</label>
|
||||||
<input type="text" name="redacted_username" value="${config['redacted_username']}" size="36">
|
<input type="text" name="redacted_username" value="${config['redacted_username']}" size="36">
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ _CONFIG_DEFINITIONS = {
|
|||||||
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
|
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
|
||||||
'WAIT_UNTIL_RELEASE_DATE': (int, 'General', 0),
|
'WAIT_UNTIL_RELEASE_DATE': (int, 'General', 0),
|
||||||
'REDACTED': (int, 'Redacted', 0),
|
'REDACTED': (int, 'Redacted', 0),
|
||||||
|
'REDACTED_APIKEY': (str, 'Redacted', ''),
|
||||||
'REDACTED_USERNAME': (str, 'Redacted', ''),
|
'REDACTED_USERNAME': (str, 'Redacted', ''),
|
||||||
'REDACTED_PASSWORD': (str, 'Redacted', ''),
|
'REDACTED_PASSWORD': (str, 'Redacted', ''),
|
||||||
'REDACTED_RATIO': (str, 'Redacted', ''),
|
'REDACTED_RATIO': (str, 'Redacted', ''),
|
||||||
|
|||||||
@@ -1590,9 +1590,9 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
|
|||||||
if not orpheusobj or not orpheusobj.logged_in():
|
if not orpheusobj or not orpheusobj.logged_in():
|
||||||
try:
|
try:
|
||||||
logger.info("Attempting to log in to Orpheus.network...")
|
logger.info("Attempting to log in to Orpheus.network...")
|
||||||
orpheusobj = gazelleapi.GazelleAPI(headphones.CONFIG.ORPHEUS_USERNAME,
|
orpheusobj = gazelleapi.GazelleAPI(username=headphones.CONFIG.ORPHEUS_USERNAME,
|
||||||
headphones.CONFIG.ORPHEUS_PASSWORD,
|
password=headphones.CONFIG.ORPHEUS_PASSWORD,
|
||||||
headphones.CONFIG.ORPHEUS_URL)
|
url=headphones.CONFIG.ORPHEUS_URL)
|
||||||
orpheusobj._login()
|
orpheusobj._login()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
orpheusobj = None
|
orpheusobj = None
|
||||||
@@ -1726,9 +1726,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
|
|||||||
if not redobj or not redobj.logged_in():
|
if not redobj or not redobj.logged_in():
|
||||||
try:
|
try:
|
||||||
logger.info("Attempting to log in to Redacted...")
|
logger.info("Attempting to log in to Redacted...")
|
||||||
redobj = gazelleapi.GazelleAPI(headphones.CONFIG.REDACTED_USERNAME,
|
redobj = gazelleapi.GazelleAPI(apikey=headphones.CONFIG.REDACTED_APIKEY,
|
||||||
headphones.CONFIG.REDACTED_PASSWORD,
|
url=providerurl)
|
||||||
providerurl)
|
|
||||||
redobj._login()
|
redobj._login()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
redobj = None
|
redobj = None
|
||||||
|
|||||||
@@ -1242,6 +1242,7 @@ class WebInterface(object):
|
|||||||
"orpheus_ratio": headphones.CONFIG.ORPHEUS_RATIO,
|
"orpheus_ratio": headphones.CONFIG.ORPHEUS_RATIO,
|
||||||
"orpheus_url": headphones.CONFIG.ORPHEUS_URL,
|
"orpheus_url": headphones.CONFIG.ORPHEUS_URL,
|
||||||
"use_redacted": checked(headphones.CONFIG.REDACTED),
|
"use_redacted": checked(headphones.CONFIG.REDACTED),
|
||||||
|
"redacted_apikey": headphones.CONFIG.REDACTED_APIKEY,
|
||||||
"redacted_username": headphones.CONFIG.REDACTED_USERNAME,
|
"redacted_username": headphones.CONFIG.REDACTED_USERNAME,
|
||||||
"redacted_password": headphones.CONFIG.REDACTED_PASSWORD,
|
"redacted_password": headphones.CONFIG.REDACTED_PASSWORD,
|
||||||
"redacted_ratio": headphones.CONFIG.REDACTED_RATIO,
|
"redacted_ratio": headphones.CONFIG.REDACTED_RATIO,
|
||||||
|
|||||||
+13
-9
@@ -41,11 +41,12 @@ class GazelleAPI(object):
|
|||||||
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'}
|
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'}
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, username=None, password=None, url=None):
|
def __init__(self, apikey=None, username=None, password=None, url=None):
|
||||||
self.session = requests.session()
|
self.session = requests.session()
|
||||||
self.session.headers = self.default_headers
|
self.session.headers = self.default_headers
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.apikey = apikey
|
||||||
self.authkey = None
|
self.authkey = None
|
||||||
self.passkey = None
|
self.passkey = None
|
||||||
self.userid = None
|
self.userid = None
|
||||||
@@ -94,14 +95,17 @@ class GazelleAPI(object):
|
|||||||
|
|
||||||
self.wait_for_rate_limit()
|
self.wait_for_rate_limit()
|
||||||
|
|
||||||
loginpage = self.site + 'login.php'
|
if self.apikey is not None:
|
||||||
data = {'username': self.username,
|
self.session.headers["Authorization"] = self.apikey
|
||||||
'password': self.password,
|
else:
|
||||||
'keeplogged': '1'}
|
loginpage = self.site + 'login.php'
|
||||||
r = self.session.post(loginpage, data=data, timeout=self.default_timeout, headers=self.default_headers)
|
data = {'username': self.username,
|
||||||
self.past_request_timestamps.append(time.time())
|
'password': self.password,
|
||||||
if r.status_code != 200:
|
'keeplogged': '1'}
|
||||||
raise LoginException("Login returned status code %s" % r.status_code)
|
r = self.session.post(loginpage, data=data, timeout=self.default_timeout, headers=self.default_headers)
|
||||||
|
self.past_request_timestamps.append(time.time())
|
||||||
|
if r.status_code != 200:
|
||||||
|
raise LoginException("Login returned status code %s" % r.status_code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
accountinfo = self.request('index', autologin=False)
|
accountinfo = self.request('index', autologin=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user