mirror of
https://github.com/LukeHagar/plex-sdk-docs.git
synced 2025-12-06 20:47:46 +00:00
69 lines
1.7 KiB
Plaintext
69 lines
1.7 KiB
Plaintext
{/* Start Python Server Options */}
|
|
|
|
### Select Server by Index
|
|
|
|
You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
```python
|
|
import plex_api
|
|
|
|
s = plex_api.PlexAPI(
|
|
server_idx=0,
|
|
access_token="<YOUR_API_KEY_HERE>",
|
|
)
|
|
|
|
|
|
res = s.server.get_server_capabilities()
|
|
|
|
if res.object is not None:
|
|
# handle response
|
|
pass
|
|
```
|
|
|
|
#### Variables
|
|
|
|
Some of the server options above contain variables. If you want to set the values of those variables, the following optional parameters are available when initializing the SDK client instance:
|
|
* `protocol: models.ServerProtocol`
|
|
* `ip: str`
|
|
* `port: str`
|
|
|
|
### Override Server URL Per-Client
|
|
|
|
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
|
```python
|
|
import plex_api
|
|
|
|
s = plex_api.PlexAPI(
|
|
server_url="{protocol}://{ip}:{port}",
|
|
access_token="<YOUR_API_KEY_HERE>",
|
|
)
|
|
|
|
|
|
res = s.server.get_server_capabilities()
|
|
|
|
if res.object is not None:
|
|
# handle response
|
|
pass
|
|
```
|
|
|
|
### Override Server URL Per-Operation
|
|
|
|
The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
|
|
```python
|
|
import plex_api
|
|
|
|
s = plex_api.PlexAPI()
|
|
|
|
|
|
res = s.plex.get_pin(server_url="https://plex.tv/api/v2", x_plex_client_identifier='<value>', strong=False)
|
|
|
|
if res.object is not None:
|
|
# handle response
|
|
pass
|
|
```
|
|
{/* End Python Server Options */}
|