Api
Api(url, username, password, client, use_https=True, use_token=True, request_method=RequestMethod.GET)
Class in charge of managing the access to the REST API of the OpenSubsonic server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The base URL that points to the server,
without the |
required |
username |
str
|
The name of the user to login as in the API. |
required |
password |
str
|
The password of the user to login as in the API. |
required |
client |
str
|
The name of the client to report to the API. |
required |
use_https |
bool
|
If HTTPS should be used. |
True
|
use_token |
bool
|
If the modern token based authentication should be used. |
True
|
request_method |
RequestMethod
|
If the requests should send the data as GET parameters or POST form data. |
GET
|
Source code in .venv/lib/python3.11/site-packages/knuckles/_api.py
generate_url(endpoint, extra_params)
Using the PreparedRequest object of the Requests request package generates a valid URL for any endpoint with a valid authentication parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
The endpoint to be appended in the URL, without the
leading |
required |
extra_params |
dict[str, Any]
|
The extra parameters to be added to the URL. |
required |
Returns:
Type | Description |
---|---|
str
|
A valid URL pointing to the desired endpoint and with the requested parameters, including the ones needed for authentication. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_api.py
json_request(endpoint, extra_params=None)
Makes a request to the OpenSubsonic server REST API and returns the
data from the subsonic_response
property. Should never be used
with non-json compatible endpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
The endpoint to be appended in the URL, without the
leading |
required |
extra_params |
dict[str, Any] | None
|
Extra parameters to the added to the request. |
None
|
Raises:
Type | Description |
---|---|
code_error
|
Raise an error if the server reports and issue with the
request in the form of a code error, the raised follows
the form |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The data contained in the |
Source code in .venv/lib/python3.11/site-packages/knuckles/_api.py
raw_request(endpoint, extra_params=None)
Makes a request to the OpenSubsonic server REST API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
The endpoint to be appended in the URL, without the
leading |
required |
extra_params |
dict[str, Any] | None
|
Extra parameters to the added to the request. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The
|