mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Fix getting new pms_identifier for server only
This commit is contained in:
parent
a957e8eb4f
commit
36de20dd75
1 changed files with 41 additions and 27 deletions
|
@ -383,7 +383,6 @@ class PlexTV(object):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
plextv_resources = self.get_plextv_resources(include_https=include_https)
|
plextv_resources = self.get_plextv_resources(include_https=include_https)
|
||||||
server_urls = []
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xml_parse = minidom.parseString(plextv_resources)
|
xml_parse = minidom.parseString(plextv_resources)
|
||||||
|
@ -400,36 +399,51 @@ class PlexTV(object):
|
||||||
logger.warn(u"PlexPy PlexTV :: Unable to parse XML for get_server_urls: %s." % e)
|
logger.warn(u"PlexPy PlexTV :: Unable to parse XML for get_server_urls: %s." % e)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# Function to get all connections for a device
|
||||||
|
def get_connections(device):
|
||||||
|
conn = []
|
||||||
|
connections = device.getElementsByTagName('Connection')
|
||||||
|
|
||||||
|
for c in connections:
|
||||||
|
server_details = {"protocol": helpers.get_xml_attr(c, 'protocol'),
|
||||||
|
"address": helpers.get_xml_attr(c, 'address'),
|
||||||
|
"port": helpers.get_xml_attr(c, 'port'),
|
||||||
|
"uri": helpers.get_xml_attr(c, 'uri'),
|
||||||
|
"local": helpers.get_xml_attr(c, 'local')
|
||||||
|
}
|
||||||
|
conn.append(server_details)
|
||||||
|
|
||||||
|
return conn
|
||||||
|
|
||||||
|
server_urls = []
|
||||||
|
|
||||||
|
# Try to match the device
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if helpers.get_xml_attr(a, 'clientIdentifier') == server_id:
|
if helpers.get_xml_attr(a, 'clientIdentifier') == server_id:
|
||||||
connections = a.getElementsByTagName('Connection')
|
server_urls = get_connections(a)
|
||||||
for connection in connections:
|
break
|
||||||
server_details = {"protocol": helpers.get_xml_attr(connection, 'protocol'),
|
|
||||||
"address": helpers.get_xml_attr(connection, 'address'),
|
|
||||||
"port": helpers.get_xml_attr(connection, 'port'),
|
|
||||||
"uri": helpers.get_xml_attr(connection, 'uri'),
|
|
||||||
"local": helpers.get_xml_attr(connection, 'local')
|
|
||||||
}
|
|
||||||
|
|
||||||
server_urls.append(server_details)
|
# Else no device match found
|
||||||
# Else try to match the PMS_IP and PMS_PORT
|
if not server_urls:
|
||||||
else:
|
# Try to match the PMS_IP and PMS_PORT
|
||||||
|
for a in xml_head:
|
||||||
|
if helpers.get_xml_attr(a, 'provides') == 'server':
|
||||||
connections = a.getElementsByTagName('Connection')
|
connections = a.getElementsByTagName('Connection')
|
||||||
|
|
||||||
for connection in connections:
|
for connection in connections:
|
||||||
if helpers.get_xml_attr(connection, 'address') == plexpy.CONFIG.PMS_IP and \
|
if helpers.get_xml_attr(connection, 'address') == plexpy.CONFIG.PMS_IP and \
|
||||||
int(helpers.get_xml_attr(connection, 'port')) == plexpy.CONFIG.PMS_PORT:
|
int(helpers.get_xml_attr(connection, 'port')) == plexpy.CONFIG.PMS_PORT:
|
||||||
|
|
||||||
plexpy.CONFIG.PMS_IDENTIFIER = helpers.get_xml_attr(a, 'clientIdentifier')
|
plexpy.CONFIG.PMS_IDENTIFIER = helpers.get_xml_attr(a, 'clientIdentifier')
|
||||||
|
plexpy.CONFIG.write()
|
||||||
|
|
||||||
logger.info(u"PlexPy PlexTV :: PMS identifier changed from %s to %s." % \
|
logger.info(u"PlexPy PlexTV :: PMS identifier changed from %s to %s." % \
|
||||||
(server_id, plexpy.CONFIG.PMS_IDENTIFIER))
|
(server_id, plexpy.CONFIG.PMS_IDENTIFIER))
|
||||||
|
|
||||||
server_details = {"protocol": helpers.get_xml_attr(connection, 'protocol'),
|
server_urls = get_connections(a)
|
||||||
"address": helpers.get_xml_attr(connection, 'address'),
|
break
|
||||||
"port": helpers.get_xml_attr(connection, 'port'),
|
|
||||||
"uri": helpers.get_xml_attr(connection, 'uri'),
|
if server_urls:
|
||||||
"local": helpers.get_xml_attr(connection, 'local')
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
|
|
||||||
return server_urls
|
return server_urls
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue