Media Retrieval
MediaRetrieval(api, subsonic)
Class that contains all the methods needed to interact with the media retrieval endpoints in the Subsonic API.
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
download(song_or_video_id, file_or_directory_path, use_stream=False)
Download a song or video from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
song_or_video_id |
str
|
The ID of the song or video to download. |
required |
file_or_directory_path |
Path
|
The path where the downloaded file should be saved. If the given path is a directory then the file will be downloaded inside of it, if its a valid file path it will be downloaded using this exact filename. |
required |
Returns:
Type | Description |
---|---|
Path
|
The path where the song or video was finally saved. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
get_avatar(username, file_or_directory_path)
Download the avatar image of a user from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user to get its avatar from. |
required |
file_or_directory_path |
Path
|
The path where the downloaded file should be saved. If the given path is a directory then the file will be downloaded inside of it, if its a valid file path it will be downloaded using this exact filename. |
required |
Returns:
Type | Description |
---|---|
Path
|
The path where the avatar image was finally saved. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
get_captions(caption_id, file_or_directory_path, subtitles_file_format=SubtitlesFileFormat.VTT)
Download a video caption file from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption_id |
str
|
The ID of the caption to download. |
required |
file_or_directory_path |
Path
|
The path where the downloaded file should be saved. If the given path is a directory then the file will be downloaded inside of it, if its a valid file path it will be downloaded using this exact filename. |
required |
subtitles_file_format |
SubtitlesFileFormat
|
The format that the subtitle file should have. |
VTT
|
Returns:
Type | Description |
---|---|
Path
|
The path where the captions was finally saved. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
get_cover_art(cover_art_id, file_or_directory_path, size=None)
Download the cover art from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cover_art_id |
str
|
The ID of the cover art to download. |
required |
file_or_directory_path |
Path
|
The path where the downloaded file should be saved. If the given path is a directory then the file will be downloaded inside of it, if its a valid file path it will be downloaded using this exact filename. |
required |
size |
int | None
|
The width in pixels that the image should have, the cover arts are always squares. |
None
|
Returns:
Type | Description |
---|---|
Path
|
The path where the captions was finally saved. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
get_lyrics(artist_name=None, song_title=None)
Get the lyrics of a song.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artist_name |
str | None
|
The name of the artist that made the song to get its lyrics from. |
None
|
song_title |
str | None
|
The title of the song to get its lyrics from. |
None
|
Returns:
Type | Description |
---|---|
Lyrics
|
An object that contains all the info about the requested lyrics. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
hls(song_or_video_id, custom_bitrates=None, audio_track_id=None)
Get the URL required to stream a song or video with hls.m3u8.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
song_or_video_id |
str
|
The ID of the song or video to stream. |
required |
custom_bitrates |
list[str] | None
|
The bitrate that the server should try to
limit the stream to. If more that one is specified the
server will create a |
None
|
audio_track_id |
str | None
|
The ID of an audio track to be added to the stream if video is being streamed. |
None
|
Returns:
Type | Description |
---|---|
str
|
An URL with all the needed parameters to start a streaming with hls.m3u8 using a GET request. |
Source code in .venv/lib/python3.11/site-packages/knuckles/_media_retrieval.py
stream(song_or_video_id, max_bitrate_rate=None, stream_format=None, time_offset=None, size=None, estimate_content_length=None, converted=None)
Get the URL required to stream a song or video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
song_or_video_id |
str
|
The ID of the song or video to get its steam URL |
required |
max_bitrate_rate |
int | None
|
The max bitrate the stream should have. |
None
|
stream_format |
str | None
|
The format the song or video should be. Warning: The available formats are dependant of the server implementation. The only secure format is "raw", which disabled transcoding at all. |
None
|
time_offset |
int | None
|
An offset where the stream should start. It may not work with video, depending of the server configuration. |
None
|
size |
str | None
|
The maximum resolution of the streaming in the format |
None
|
estimate_content_length |
bool | None
|
When set to true the response with have
the |
None
|
converted |
bool | None
|
If set to true the server will try to stream a
transcoded version in |
None
|
Returns:
Type | Description |
---|---|
str
|
An URL with all the needed parameters to start a streaming using a GET request. |