Station Playlist Helper

class AzuracastPy.models.helpers.PlaylistHelper(_station)

Provides a set of functions to interact with playlists.

__call__(id: int) Playlist

Retrieves a specific playlist from the station.

Parameters:

id – The numerical ID of the playlist to be retrieved.

Returns:

A Playlist object.

Usage:

playlist = station.playlist(1)
__init__(_station)

Initializes a PlaylistHelper instance.

Note

This class should not be initialized directly. Instead, obtain an instance via: playlist.

create(name: str, source: PlaylistSources = PlaylistSources.SONGS, type: PlaylistTypes = PlaylistTypes.DEFAULT, order: PlaylistOrders = PlaylistOrders.SHUFFLE, avoid_duplicates: bool = True, allow_requests: bool = True, play_per_value: int = 0, weight: int = 3, include_in_on_demand: bool = False, is_jingle: bool = False, remote_url: str | None = None, remote_type: PlaylistRemoteTypes = PlaylistRemoteTypes.STREAM, remote_buffer: int = 0, schedule: List[Dict[str, Any]] | None = None) Playlist

Adds a new playlist to the station.

Parameters:
  • name – The name of the playlist.

  • source – Specify where the playlist gets its contents from. Default: PlaylistSources.SONGS.

  • type – The internal play-type of the playlist. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: PlaylistTypes.DEFAULT.

  • order – Determines the playback order of the songs in the playlist. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: PlaylistOrders.SHUFFLE.

  • avoid_duplicates – Determines whether duplicate artists and track titles will be avoided when playing media from this playlist. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: True.

  • allow_requests – Determines whether users will be able to request media that is on this playlist. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: True.

  • play_per_value – This value acts as the corresponding value for the ONCE_PER_X_SONGS, ONCE_PER_HOUR and ONCE_PER_X_MINUTES playlist types. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: 0.

  • weight – The frequency of the playlist to be played when compared to playlists. This is the value for the DEFAULT playlist type. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: 3.

  • include_in_on_demand – Determines whether only songs that are in playlists with this setting enabled will be visible. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: False.

  • is_jingle – Set to True to prevent metadata from being sent to the AutoDJ for files in this playlist. Not needed if source is set to PlaylistSources.REMOTE_URL. Default: False.

  • remote_url – (Optional) The source URL for the playlist’s contents. Not needed if source is set to PlaylistSources.SONGS. Default: None.

  • remote_type – Specify the type of the remote_url. Not needed if source is set to PlaylistSources.SONGS. Default: PlaylistRemoteTypes.STREAM.

  • remote_buffer – The length of playback time that Liquidsoap should buffer when playing this remote playlist. Not needed if source is set to PlaylistSources.SONGS. Default: 0.

  • schedule – The structure representing the schedule list of the playlist. This can be generated using the generate_schedule_items() function. Default: None.

Returns:

A Playlist object for the newly created playlist.

Usage:

from AzuracastPy.enums import PlaylistTypes

playlist = station.playlist.create(
    name="New playlist",
    type=PlaylistTypes.ONCE_PER_X_MINUTES,
    play_per_value=5
)
generate_schedule_item(start_time: str, end_time: str, start_date: str | None = None, end_date: str | None = None, days: List[str] | None = None, loop_once: bool = False) Dict[str, Any]

Generates a single schedule item for a playlist.

Parameters:
  • start_time – The starting time of the schedule, in this format: "HOUR:MINUTES".

  • end_time – The ending time of the schedule, in this format: "HOUR:MINUTES".

  • start_date – (Optional) The starting date of the schedule, in this format: "YEAR-MONTH-DAY". Default: None.

  • end_date – (Optional) The ending date of the schedule, in this format: "YEAR-MONTH-DAY". Default: None.

  • days – (Optional) A list of the days that the playlist will play. Default: None.

  • loop_once – Determines if the playlist will be looped through only once. Default: False.

Usage:

item = station.playlist.generate_schedule_item(
    start_time="12:32",
    end_time="23:10",
    start_date="2024-09-08",
    end_date="2025-07-08",
    days=["monday", "thursday"],
    loop_once=False
)
generate_schedule_items(*args) List[Dict[str, Any]]
Generates a list of schedule items for a playlist by using the

generate_schedule_item() function on each argument.

Parameters:

args – Tuples in the format of (start_time, end_time, start_date, end_date, days, loop_once). start_time and end_time are mandatory values. The rest of the tuple’s values can be None.

Usage:

items = station.playlist.generate_schedule_items(
    ("12:32", "23:10", "2024-09-08", "2025-07-08", None, False),
    ("12:32", "23:10", "2024-09-18", "2025-07-08", ["monday", "thursday"], True)
)