mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Fix getting pms_url when multiple connections published
* Fixes bug grabbing the wrong pms_url when multiple local/remote connections are published to plex.tv * This tries to find the connection with the matching address first, otherwise grabs the first valid local/remote connection (prior behaviour)
This commit is contained in:
parent
6a72923182
commit
2f5f0ba1e1
2 changed files with 23 additions and 23 deletions
|
@ -39,7 +39,6 @@ function showMsg(msg,loader,timeout,ms,error) {
|
|||
}
|
||||
if (error) {
|
||||
feedback.css("background-color", "rgba(255,0,0,0.5)");
|
||||
console.log('is error');
|
||||
}
|
||||
$(feedback).html(message);
|
||||
feedback.fadeIn();
|
||||
|
@ -49,6 +48,7 @@ function showMsg(msg,loader,timeout,ms,error) {
|
|||
message.fadeOut(function(){
|
||||
$(this).remove();
|
||||
feedback.fadeOut();
|
||||
feedback.css("background-color", "");
|
||||
});
|
||||
},ms);
|
||||
}
|
||||
|
|
|
@ -71,37 +71,37 @@ def get_real_pms_url():
|
|||
|
||||
if plexpy.CONFIG.PMS_SSL:
|
||||
result = PlexTV().get_server_urls(include_https=True)
|
||||
process_urls = True
|
||||
elif plexpy.CONFIG.PMS_IS_REMOTE:
|
||||
result = PlexTV().get_server_urls(include_https=False)
|
||||
process_urls = True
|
||||
else:
|
||||
result = PlexTV().get_server_urls(include_https=False)
|
||||
process_urls = False
|
||||
|
||||
if process_urls:
|
||||
found_url = False
|
||||
|
||||
# Only need to retrieve PMS_URL if using SSL
|
||||
if plexpy.CONFIG.PMS_SSL:
|
||||
if result:
|
||||
for item in result:
|
||||
if plexpy.CONFIG.PMS_IS_REMOTE and item['local'] == '0':
|
||||
found_url = True
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', item['uri'])
|
||||
plexpy.CONFIG.write()
|
||||
logger.info(u"PlexPy PlexTV :: Server URL retrieved.")
|
||||
if not plexpy.CONFIG.PMS_IS_REMOTE and item['local'] == '1' and 'plex.direct' in item['uri']:
|
||||
found_url = True
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', item['uri'])
|
||||
if plexpy.CONFIG.PMS_IS_REMOTE:
|
||||
# Get all remote connections
|
||||
connections = [c for c in result if c['local'] == '0' and 'plex.direct' in c['uri']]
|
||||
else:
|
||||
# Get all local connections
|
||||
connections = [c for c in result if c['local'] == '1' and 'plex.direct' in c['uri']]
|
||||
|
||||
if connections:
|
||||
# Get connection with matching address, otherwise return first connection
|
||||
conn = next((c for c in connections if c['address'] == plexpy.CONFIG.PMS_IP), connections[0])
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', conn['uri'])
|
||||
plexpy.CONFIG.write()
|
||||
logger.info(u"PlexPy PlexTV :: Server URL retrieved.")
|
||||
|
||||
if not found_url:
|
||||
# get_server_urls() failed or PMS_URL not found, fallback url doesn't use SSL
|
||||
if not plexpy.CONFIG.PMS_URL:
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', fallback_url)
|
||||
plexpy.CONFIG.write()
|
||||
logger.warn(u"PlexPy PlexTV :: Unable to retrieve server URLs. Using user-defined value.")
|
||||
logger.warn(u"PlexPy PlexTV :: Unable to retrieve server URLs. Using user-defined value without SSL.")
|
||||
|
||||
# Not using SSL, remote has no effect
|
||||
else:
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', fallback_url)
|
||||
plexpy.CONFIG.write()
|
||||
logger.info(u"PlexPy PlexTV :: Using user-defined URL.")
|
||||
|
||||
|
||||
class PlexTV(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue