(plexIP, plexApiKey, plexPort, plexViaHttps)
| 163 | // "unclaimed server" playlist scope for playlists to be visible in Plex Web. |
| 164 | // claimed is null when the server is unreachable or the response is unexpected. |
| 165 | async getServerIdentityWithParams(plexIP, plexApiKey, plexPort, plexViaHttps) { |
| 166 | try { |
| 167 | const config = configModule.getConfig(); |
| 168 | const baseUrl = this.getBaseUrl(plexIP, config, plexPort, plexViaHttps); |
| 169 | if (!baseUrl) { |
| 170 | logger.warn('Missing Plex server URL for identity check'); |
| 171 | return { claimed: null, machineIdentifier: null }; |
| 172 | } |
| 173 | |
| 174 | const params = plexApiKey ? { 'X-Plex-Token': plexApiKey } : {}; |
| 175 | const response = await axios.get(`${baseUrl}/identity`, { |
| 176 | params, |
| 177 | timeout: PLEX_REQUEST_TIMEOUT_MS, |
| 178 | }); |
| 179 | |
| 180 | const container = response.data?.MediaContainer || {}; |
| 181 | const claimed = typeof container.claimed === 'boolean' ? container.claimed : null; |
| 182 | return { claimed, machineIdentifier: container.machineIdentifier || null }; |
| 183 | } catch (error) { |
| 184 | logger.warn({ err: error }, 'Failed to read Plex server identity'); |
| 185 | return { claimed: null, machineIdentifier: null }; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | async getAuthUrl() { |
| 190 | try { |
no test coverage detected