Use plex.direct url instead of local ip to use correct SSL certificate; thus fix artwork caching
- Fixes #461 - Migration necessary: re-connect to PMS to use plex.direct URI
This commit is contained in:
parent
8b1d04af79
commit
f0195f14aa
2 changed files with 30 additions and 40 deletions
|
@ -212,38 +212,28 @@ def discover_pms(token=None):
|
||||||
LOG.info('No plex token supplied, only checked LAN for available PMS')
|
LOG.info('No plex token supplied, only checked LAN for available PMS')
|
||||||
plex_pms_list = []
|
plex_pms_list = []
|
||||||
|
|
||||||
# See if we found a PMS both locally and using plex.tv. If so, use local
|
# Add PMS found only in the LAN to the Plex.tv PMS list
|
||||||
# connection data
|
|
||||||
all_pms = []
|
|
||||||
for pms in local_pms_list:
|
for pms in local_pms_list:
|
||||||
for i, plex_pms in enumerate(plex_pms_list):
|
for plex_pms in plex_pms_list:
|
||||||
if pms['machineIdentifier'] == plex_pms['machineIdentifier']:
|
if pms['machineIdentifier'] == plex_pms['machineIdentifier']:
|
||||||
# Update with GDM data - potentially more reliable than plex.tv
|
continue
|
||||||
LOG.debug('Found this PMS also in the LAN: %s', plex_pms)
|
|
||||||
plex_pms['ip'] = pms['ip']
|
|
||||||
plex_pms['port'] = pms['port']
|
|
||||||
plex_pms['local'] = True
|
|
||||||
# Use all the other data we know from plex.tv
|
|
||||||
pms = plex_pms
|
|
||||||
# Remove this particular pms since we already know it
|
|
||||||
plex_pms_list.pop(i)
|
|
||||||
break
|
|
||||||
https = _pms_https_enabled('%s:%s' % (pms['ip'], pms['port']))
|
|
||||||
if https is None:
|
|
||||||
# Error contacting url. Skip and ignore this PMS for now
|
|
||||||
continue
|
|
||||||
elif https is True:
|
|
||||||
pms['scheme'] = 'https'
|
|
||||||
pms['baseURL'] = 'https://%s:%s' % (pms['ip'], pms['port'])
|
|
||||||
else:
|
else:
|
||||||
pms['scheme'] = 'http'
|
# Only found PMS using GDM - add it to the PMS from plex.tv
|
||||||
pms['baseURL'] = 'http://%s:%s' % (pms['ip'], pms['port'])
|
https = _pms_https_enabled('%s:%s' % (pms['ip'], pms['port']))
|
||||||
all_pms.append(pms)
|
if https is None:
|
||||||
# Now add the remaining PMS from plex.tv (where we already checked connect.)
|
# Error contacting url. Skip and ignore this PMS for now
|
||||||
for plex_pms in plex_pms_list:
|
LOG.error('Could not contact PMS %s but we should have', pms)
|
||||||
all_pms.append(plex_pms)
|
continue
|
||||||
LOG.debug('Found the following PMS in total: %s', all_pms)
|
elif https is True:
|
||||||
return all_pms
|
pms['scheme'] = 'https'
|
||||||
|
else:
|
||||||
|
pms['scheme'] = 'http'
|
||||||
|
pms['baseURL'] = '%s://%s:%s' % (pms['scheme'],
|
||||||
|
pms['ip'],
|
||||||
|
pms['port'])
|
||||||
|
plex_pms_list.append(pms)
|
||||||
|
LOG.debug('Found the following PMS in total: %s', plex_pms_list)
|
||||||
|
return plex_pms_list
|
||||||
|
|
||||||
|
|
||||||
def _plex_gdm():
|
def _plex_gdm():
|
||||||
|
@ -414,17 +404,11 @@ def _pms_list_from_plex_tv(token):
|
||||||
|
|
||||||
def _poke_pms(pms, queue):
|
def _poke_pms(pms, queue):
|
||||||
data = pms['connections'][0].attrib
|
data = pms['connections'][0].attrib
|
||||||
if data['local'] == '1':
|
url = data['uri']
|
||||||
protocol = data['protocol']
|
if url.count(':') == 1:
|
||||||
address = data['address']
|
url = '%s:%s' % (url, data['port'])
|
||||||
port = data['port']
|
protocol, address, port = url.split(':', 2)
|
||||||
url = '%s://%s:%s' % (protocol, address, port)
|
address = address.replace('/', '')
|
||||||
else:
|
|
||||||
url = data['uri']
|
|
||||||
if url.count(':') == 1:
|
|
||||||
url = '%s:%s' % (url, data['port'])
|
|
||||||
protocol, address, port = url.split(':', 2)
|
|
||||||
address = address.replace('/', '')
|
|
||||||
xml = DU().downloadUrl('%s/identity' % url,
|
xml = DU().downloadUrl('%s/identity' % url,
|
||||||
authenticate=False,
|
authenticate=False,
|
||||||
headerOptions={'X-Plex-Token': pms['token']},
|
headerOptions={'X-Plex-Token': pms['token']},
|
||||||
|
|
|
@ -21,4 +21,10 @@ def check_migration():
|
||||||
# Set the new PKC theMovieDB key
|
# Set the new PKC theMovieDB key
|
||||||
settings('themoviedbAPIKey', value='19c90103adb9e98f2172c6a6a3d85dc4')
|
settings('themoviedbAPIKey', value='19c90103adb9e98f2172c6a6a3d85dc4')
|
||||||
|
|
||||||
|
if not compare_version(v.ADDON_VERSION, '2.0.24'):
|
||||||
|
log.info('Migrating to version 2.0.24')
|
||||||
|
# Need to re-connect with PMS to pick up on plex.direct URIs
|
||||||
|
settings('ipaddress', value='')
|
||||||
|
settings('port', value='')
|
||||||
|
|
||||||
settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|
settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|
||||||
|
|
Loading…
Reference in a new issue