Skip to content

Music Folder

MusicFolder(subsonic, id, name=None)

Bases: Model

Object that holds all the info about a music folder

Attributes:

Name Type Description
id

The ID of the music folder.

name

The name of the music folder.

Source code in .venv/lib/python3.11/site-packages/knuckles/models/_music_folder.py
def __init__(self, subsonic: "Subsonic", id: str, name: str | None = None) -> None:
    super().__init__(subsonic)

    self.id = id
    self.name = name

generate()

Return a new music folder object with all the data updated from the API, using the endpoint that return the most information possible.

Useful for making copies with updated data or updating the object itself with immutability, e.g., foo = foo.generate().

Returns:

Type Description
MusicFolder

A new object with all the updated info.

Source code in .venv/lib/python3.11/site-packages/knuckles/models/_music_folder.py
def generate(self) -> "MusicFolder":
    """Return a new music folder object with all the data updated from the
    API, using the endpoint that return the most information possible.

    Useful for making copies with updated data or updating the object
    itself with immutability, e.g., `foo = foo.generate()`.

    Returns:
        A new object with all the updated info.
    """

    music_folders = self._subsonic.browsing.get_music_folders()

    # Get the first element with the same ID
    music_folder = next(
        music_folder for music_folder in music_folders if music_folder.id == self.id
    )

    return music_folder