(ATV_udid, CSettings, IP_self, tokenDict={})
| 228 | g_PMS database for ATV_udid |
| 229 | """ |
| 230 | def discoverPMS(ATV_udid, CSettings, IP_self, tokenDict={}): |
| 231 | global g_PMS |
| 232 | g_PMS[ATV_udid] = {} |
| 233 | |
| 234 | # install plex.tv "virtual" PMS - for myPlex, PlexHome |
| 235 | declarePMS(ATV_udid, 'plex.tv', 'plex.tv', 'https', 'plex.tv', '443') |
| 236 | updatePMSProperty(ATV_udid, 'plex.tv', 'local', '-') |
| 237 | updatePMSProperty(ATV_udid, 'plex.tv', 'owned', '-') |
| 238 | updatePMSProperty(ATV_udid, 'plex.tv', 'accesstoken', tokenDict.get('MyPlex', '')) |
| 239 | |
| 240 | #debug |
| 241 | #declarePMS(ATV_udid, '2ndServer', '2ndServer', 'http', '192.168.178.22', '32400', 'local', '1', 'token') |
| 242 | #declarePMS(ATV_udid, 'remoteServer', 'remoteServer', 'http', '127.0.0.1', '1234', 'myplex', '1', 'token') |
| 243 | #debug |
| 244 | |
| 245 | if 'PlexHome' in tokenDict: |
| 246 | authtoken = tokenDict.get('PlexHome') |
| 247 | else: |
| 248 | authtoken = tokenDict.get('MyPlex', '') |
| 249 | |
| 250 | if authtoken=='': |
| 251 | # not logged into myPlex |
| 252 | # local PMS |
| 253 | if CSettings.getSetting('enable_plexgdm')=='False': |
| 254 | # defined in setting.cfg |
| 255 | ip = CSettings.getSetting('ip_pms') |
| 256 | # resolve hostname if needed |
| 257 | try: |
| 258 | ip2 = socket.gethostbyname(ip) |
| 259 | if ip != ip2: |
| 260 | dprint(__name__, 0, "PlexAPI - Hostname "+ip+" resolved to "+ip2) |
| 261 | ip = ip2 |
| 262 | except: |
| 263 | dprint(__name__, 0, "PlexAPI - ip_dns "+ip+" could not be resolved") |
| 264 | |
| 265 | port = CSettings.getSetting('port_pms') |
| 266 | XML = getXMLFromPMS('http://'+ip+':'+port, '/servers', None, '') |
| 267 | |
| 268 | if XML==False: |
| 269 | pass # no response from manual defined server (Settings.cfg) |
| 270 | else: |
| 271 | Server = XML.find('Server') |
| 272 | uuid = Server.get('machineIdentifier') |
| 273 | name = Server.get('name') |
| 274 | |
| 275 | declarePMS(ATV_udid, uuid, name, 'http', ip, port) # dflt: token='', local, owned |
| 276 | # todo - check IP to verify "local"? |
| 277 | |
| 278 | else: |
| 279 | # PlexGDM |
| 280 | PMS_list = PlexGDM() |
| 281 | for uuid in PMS_list: |
| 282 | PMS = PMS_list[uuid] |
| 283 | declarePMS(ATV_udid, PMS['uuid'], PMS['serverName'], 'http', PMS['ip'], PMS['port']) # dflt: token='', local, owned |
| 284 | |
| 285 | else: |
| 286 | # MyPlex servers |
| 287 | getPMSListFromMyPlex(ATV_udid, authtoken) |
nothing calls this directly
no test coverage detected