Compare commits

..

6 Commits

Author SHA1 Message Date
JonnyWong16
03751abc0e v2.1.22 2018-10-05 21:04:17 -07:00
JonnyWong16
a94207691f Improve OAuth polling 2018-09-30 21:05:12 -07:00
JonnyWong16
dbc53ca710 Fix websocket not connecting after setup wizard 2018-09-29 15:32:13 -07:00
JonnyWong16
4c9ddbd8b7 Fix incorrectly showing 127.0.0.1 server in setup wizard 2018-09-29 15:31:55 -07:00
JonnyWong16
045c69f5d8 Catch exception when retrieiving data for notifier configs 2018-09-28 18:21:04 -07:00
JonnyWong16
71ae314c46 Make sure proxy handler priority is before auth handler (Fixes Tautulli/Tautulli-Issues#123) 2018-09-27 18:05:28 -07:00
7 changed files with 73 additions and 59 deletions

View File

@@ -1,5 +1,16 @@
# Changelog # Changelog
## v2.1.22 (2018-10-05)
* Notifications:
* Fix: Notification agent settings not loading when failed to retrieve some data.
* UI:
* Fix: Incorrectly showing localhost server in the setup wizard.
* Other:
* Fix: Incorrect redirect to HTTP when HTTPS proxy header is present.
* Fix: Websocket not connecting automatically after the setup wizard.
## v2.1.21 (2018-09-21) ## v2.1.21 (2018-09-21)
* Notifications: * Notifications:

View File

@@ -611,7 +611,6 @@ function PlexOAuth(success, error, pre) {
if (typeof pre === "function") { if (typeof pre === "function") {
pre() pre()
} }
clearTimeout(polling);
closePlexOAuthWindow(); closePlexOAuthWindow();
plex_oauth_window = PopupCenter('', 'Plex-OAuth', 600, 700); plex_oauth_window = PopupCenter('', 'Plex-OAuth', 600, 700);
$(plex_oauth_window.document.body).html(plex_oauth_loader); $(plex_oauth_window.document.body).html(plex_oauth_loader);
@@ -621,37 +620,36 @@ function PlexOAuth(success, error, pre) {
const code = data.code; const code = data.code;
plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code; plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code;
polling = pin;
(function poll() { (function poll() {
polling = setTimeout(function () { $.ajax({
$.ajax({ url: 'https://plex.tv/api/v2/pins/' + pin,
url: 'https://plex.tv/api/v2/pins/' + pin, type: 'GET',
type: 'GET', headers: x_plex_headers,
headers: x_plex_headers, success: function (data) {
success: function (data) { if (data.authToken){
if (data.authToken){ closePlexOAuthWindow();
closePlexOAuthWindow(); if (typeof success === "function") {
if (typeof success === "function") { success(data.authToken)
success(data.authToken)
}
} }
}, }
error: function () { },
error: function (jqXHR, textStatus, errorThrown) {
if (textStatus !== "timeout") {
closePlexOAuthWindow(); closePlexOAuthWindow();
if (typeof error === "function") { if (typeof error === "function") {
error() error()
} }
}, }
complete: function () { },
if (!plex_oauth_window.closed){ complete: function () {
poll(); if (!plex_oauth_window.closed && polling === pin){
} else { setTimeout(function() {poll()}, 1000);
clearTimeout(polling); }
} },
}, timeout: 10000
timeout: 1000 });
});
}, 1000);
})(); })();
}, function () { }, function () {
closePlexOAuthWindow(); closePlexOAuthWindow();

View File

@@ -90,6 +90,7 @@
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<select class="form-control pms-settings selectize-pms-ip" id="pms_ip_selectize"> <select class="form-control pms-settings selectize-pms-ip" id="pms_ip_selectize">
% if config['pms_identifier']:
<option value="${config['pms_ip']}:${config['pms_port']}" <option value="${config['pms_ip']}:${config['pms_port']}"
data-identifier="${config['pms_identifier']}" data-identifier="${config['pms_identifier']}"
data-ip="${config['pms_ip']}" data-ip="${config['pms_ip']}"
@@ -99,6 +100,7 @@
data-is_cloud="${config['pms_is_cloud']}" data-is_cloud="${config['pms_is_cloud']}"
data-label="${config['pms_name'] or 'Local'}" data-label="${config['pms_name'] or 'Local'}"
selected>${config['pms_ip']}</option> selected>${config['pms_ip']}</option>
% endif
</select> </select>
</div> </div>
</div> </div>

View File

@@ -2091,25 +2091,26 @@ class JOIN(Notifier):
if self.config['api_key']: if self.config['api_key']:
params = {'apikey': self.config['api_key']} params = {'apikey': self.config['api_key']}
r = requests.get('https://joinjoaomgcd.appspot.com/_ah/api/registration/v1/listDevices', params=params) try:
r = requests.get('https://joinjoaomgcd.appspot.com/_ah/api/registration/v1/listDevices', params=params)
if r.status_code == 200:
response_data = r.json()
if response_data.get('success'):
response_devices = response_data.get('records', [])
devices.update({d['deviceName']: d['deviceName'] for d in response_devices})
else:
error_msg = response_data.get('errorMessage')
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=error_msg))
if r.status_code == 200:
response_data = r.json()
if response_data.get('success'):
response_devices = response_data.get('records', [])
devices.update({d['deviceName']: d['deviceName'] for d in response_devices})
return devices
else: else:
error_msg = response_data.get('errorMessage') logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
logger.info(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=error_msg)) logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
return devices
else:
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
return devices
else: except Exception as e:
return devices logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
return devices
def return_config_options(self): def return_config_options(self):
config_option = [{'label': 'Join API Key', config_option = [{'label': 'Join API Key',
@@ -2679,27 +2680,28 @@ class PUSHBULLET(Notifier):
return self.make_request('https://api.pushbullet.com/v2/pushes', headers=headers, json=data) return self.make_request('https://api.pushbullet.com/v2/pushes', headers=headers, json=data)
def get_devices(self): def get_devices(self):
devices = {'': ''}
if self.config['api_key']: if self.config['api_key']:
headers = {'Content-type': "application/json", headers = {'Content-type': "application/json",
'Access-Token': self.config['api_key'] 'Access-Token': self.config['api_key']
} }
try:
r = requests.get('https://api.pushbullet.com/v2/devices', headers=headers)
r = requests.get('https://api.pushbullet.com/v2/devices', headers=headers) if r.status_code == 200:
response_data = r.json()
pushbullet_devices = response_data.get('devices', [])
devices.update({d['iden']: d['nickname'] for d in pushbullet_devices if d['active']})
else:
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: "
u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
if r.status_code == 200: except Exception as e:
response_data = r.json() logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
devices = response_data.get('devices', [])
devices = {d['iden']: d['nickname'] for d in devices if d['active']}
devices.update({'': ''})
return devices
else:
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: "
u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
return {'': ''}
else: return devices
return {'': ''}
def return_config_options(self): def return_config_options(self):
config_option = [{'label': 'Pushbullet Access Token', config_option = [{'label': 'Pushbullet Access Token',

View File

@@ -1,2 +1,2 @@
PLEXPY_BRANCH = "master" PLEXPY_BRANCH = "master"
PLEXPY_RELEASE_VERSION = "v2.1.21" PLEXPY_RELEASE_VERSION = "v2.1.22"

View File

@@ -2990,7 +2990,8 @@ class WebInterface(object):
# Get new server URLs for SSL communications and get new server friendly name # Get new server URLs for SSL communications and get new server friendly name
if server_changed: if server_changed:
plextv.get_server_resources() plextv.get_server_resources()
web_socket.reconnect() if plexpy.WS_CONNECTED:
web_socket.reconnect()
# If first run, start websocket # If first run, start websocket
if first_run: if first_run:

View File

@@ -69,7 +69,7 @@ def initialize(options):
if options['http_proxy']: if options['http_proxy']:
# Overwrite cherrypy.tools.proxy with our own proxy handler # Overwrite cherrypy.tools.proxy with our own proxy handler
cherrypy.tools.proxy = cherrypy.Tool('before_handler', proxy) cherrypy.tools.proxy = cherrypy.Tool('before_handler', proxy, priority=1)
if options['http_password']: if options['http_password']:
login_allowed = ["Tautulli admin (username is '%s')" % options['http_username']] login_allowed = ["Tautulli admin (username is '%s')" % options['http_username']]
@@ -84,7 +84,7 @@ def initialize(options):
else: else:
auth_enabled = True auth_enabled = True
basic_auth_enabled = False basic_auth_enabled = False
cherrypy.tools.auth = cherrypy.Tool('before_handler', webauth.check_auth) cherrypy.tools.auth = cherrypy.Tool('before_handler', webauth.check_auth, priority=2)
else: else:
auth_enabled = basic_auth_enabled = False auth_enabled = basic_auth_enabled = False