API Objects
RainwaveClient
- class rainwaveclient.RainwaveClient(user_id: int | None = None, key: str | None = None)
A
RainwaveClientobject provides a simple interface to the Rainwave API (see https://rainwave.cc/api4/ for details about the API).- Parameters:
- art_fmt = 'https://rainwave.cc{0}_320.jpg'
The format string used to build canonical album art URLs.
- base_url = 'https://rainwave.cc/api4/'
The URL upon which all API calls are based.
- call(path: str, args: dict | None = None, method: str = 'POST') dict
Make a direct call to the API if you know the necessary path and arguments.
- Parameters:
- Returns:
The raw data returned from the API call.
- Return type:
Usage:
>>> from rainwaveclient import RainwaveClient >>> rw = RainwaveClient(5049, 'abcde12345') >>> rw.call('album', {'id': 1, 'sid': 5}) {'album': {'name': 'Bravely Default: Flying Fairy', ...}}
- property channels: list[RainwaveChannel]
A list of
RainwaveChannelobjects associated with thisRainwaveClientobject.
- property key: str
The API key to use when communicating with the API. Find your API key at https://rainwave.cc/keys/.
- property user_id: int
The User ID to use when communicating with the API. Find your User ID at https://rainwave.cc/keys/.
RainwaveChannel
- class rainwaveclient.RainwaveChannel(client: RainwaveClient, raw_info: dict)
A
RainwaveChannelobject represents one channel on the Rainwave network.Note
You should not instantiate an object of this class directly, but rather obtain one from
RainwaveClient.channels.- property albums: list[RainwaveAlbum]
A list of
RainwaveAlbumobjects in the playlist of the channel.
- property artists: list[RainwaveArtist]
A list of
RainwaveArtistobjects in the playlist of the channel.
- property client: RainwaveClient
The
RainwaveClientobject that the channel belongs to.
- get_album_by_id(album_id: int) RainwaveAlbum
Return a
RainwaveAlbumfor the given album ID. Raise anIndexErrorif there is no album with the given ID in the playlist of the channel.- Parameters:
album_id (int) – the ID of the desired album.
- get_album_by_name(name: str) RainwaveAlbum
Return a
RainwaveAlbumfor the given album name. Raise anIndexErrorif there is no album with the given name in the playlist of the channel.- Parameters:
name (str) – the name of the desired album.
- get_artist_by_id(artist_id: int) RainwaveArtist
Return a
RainwaveArtistfor the given artist ID. Raise anIndexErrorif there is no artist with the given ID in the playlist of the channel.- Parameters:
artist_id (int) – the ID of the desired artist.
- get_listener_by_id(listener_id: int) RainwaveListener
Return a
RainwaveListenerfor the given listener ID. Raise anIndexErrorif there is no listener with the given ID.- Parameters:
listener_id (int) – the ID of the desired listener.
- get_listener_by_name(name: str) RainwaveListener
Return a
RainwaveListenerfor the given listener name. Raise anIndexErrorif there is no listener with the given name currently listening to the channel.- Parameters:
name (str) – the name of the desired listener.
- get_song_by_id(song_id: int) RainwaveSong
Return a
RainwaveSongfor the given song ID. Raise anIndexErrorif there is no song with the given ID in the playlist of the channel.- Parameters:
song_id (int) – the ID of the desired song.
- property listeners: list[RainwaveListener]
A list of
RainwaveListenerobjects listening to the channel.
- property mp3_stream: str
The URL of the MP3 stream for the channel. See also
ogg_stream.
- property ogg_stream: str
The URL of the OGG stream for the channel. See also
mp3_stream.
- property requests: list[RainwaveRequest]
A list of
RainwaveRequestobjects in the request line of the channel.
- property schedule_current: RainwaveSchedule
The current
RainwaveSchedulefor the channel.
- property schedule_history: list[RainwaveSchedule]
A list of the past
RainwaveScheduleobjects for the channel. The events are sorted reverse-chronologically: the first event in the list was the most recent event.
- property schedule_next: list[RainwaveSchedule]
A list of the next
RainwaveScheduleobjects for the channel. The events are sorted chronologically: the first event in the list will happen soonest.
- property user_requests: RainwaveUserRequestQueue
A
RainwaveUserRequestQueueofRainwaveUserRequestobjects in the listener’s personal request queue.
RainwaveAlbum
- class rainwaveclient.RainwaveAlbum(channel: RainwaveChannel, raw_info: dict)
A
RainwaveAlbumobject represents one album.Note
You should not instantiate an object of this class directly, but rather obtain one from
RainwaveChannel.albums.- property added_on: datetime
A
datetime.datetimeobject specifying when the album was added to the playlist.
- property categories: list[RainwaveCategory]
A list of
RainwaveCategoryobjects representing the categories the songs on the album belong to.
- property channel: RainwaveChannel
The
RainwaveChannelobject the album belongs to.
- property cool: bool
A boolean representing whether the entire album is on cooldown.
coolwill be True if and only if every song on the album is on cooldown.
- property cool_lowest: datetime
A
datetime.datetimeobject specifying the earliest date and time a song on the album will be out of cooldown and available to play. If any song on the album is already available,cool_lowestwill be in the past.
- property fave: bool
A boolean representing whether the album is marked as a favourite or not. Change whether the album is a favourite by assigning a boolean value to this attribute.
- get_song_by_id(song_id: int) RainwaveSong
Return a
RainwaveSongfor the given song ID. Raises anIndexErrorif there is no song with the given ID on the album.- Parameters:
song_id (int) – the ID of the desired song.
- property played_last: datetime
A
datetime.datetimeobject specifying the most recent date and time when a song on the album played.
- property rating: float
The average of all ratings given to songs on the album by only the listener authenticating to the API.
- property rating_avg: float
The average of all ratings given to songs on the album by all listeners.
- property rating_complete: bool
A boolean representing whether the listener has rated all songs on the album.
- property rating_count: int
The total number of ratings given to songs on the album by all listeners.
- property rating_histogram: dict[str, int]
A dictionary representing the distribution of ratings given to all songs on the album by all listeners. For example:
>>> album.rating_histogram {'1.0': 4, '1.5': 4, '2.0': 6, ..., '4.5': 46, '5.0': 26}
- property rating_rank: int
The position of the album when albums on the channel are ranked by rating. The highest-rated album will have
rating_rank== 1.
- property request_count: int
The total number of times a song on the album was requested by any listener.
- property request_rank: int
The position of the album when albums on the channel are ranked by how often they are requested. The most-requested album will have
request_rank== 1.
- property songs: list[RainwaveSong]
A list of
RainwaveSongobjects on the album.
- property url: str
The URL of the album information page on https://rainwave.cc/
RainwaveArtist
- class rainwaveclient.RainwaveArtist(channel: RainwaveChannel, raw_info: dict)
A
RainwaveArtistobject represents one artist.Note
You should not instantiate an object of this class directly, but rather obtain one from
RainwaveChannel.artistsorRainwaveSong.artists.- property channel: RainwaveChannel
The
RainwaveChannelobject associated with the artist.
- property songs: list[RainwaveSong]
A list of
RainwaveSongobjects attributed to the artist.
RainwaveSong
- class rainwaveclient.RainwaveSong(album: RainwaveAlbum, raw_info: dict)
A
RainwaveSongobject represents one song.Note
You should not instantiate an object of this class directly, but rather obtain one from
RainwaveAlbum.songs,RainwaveArtist.songs, or some other object.- property album: RainwaveAlbum
The
RainwaveAlbumobject the song belongs to.
- property artists: list[RainwaveArtist]
A list of
RainwaveArtistobjects the song is attributed to.
- property available: bool
A boolean representing whether the song is available to play or not. Opposite of
cool.
- property categories: list[RainwaveCategory]
A list of
RainwaveCategoryobjects representing the categories the song belongs to.
- property channel_id: int
The
RainwaveChannel.idof the channel the song belongs to.
- property fave: bool
A boolean representing whether the song is marked as a fave or not. Change whether the song is a fave by assigning a boolean value to this attribute.
- property length: int
The length of the song in seconds.
RainwaveSongobjects also support len(song).
- property origin_channel_id: int
The
RainwaveChannel.idof the home channel for the song. This could be different fromchannel_idif the song is in the playlist of multiple channels.
- property origin_sid: int
See
origin_channel_id.
- property rating: float
The rating given to the song by the listener authenticating to the API. Change the rating by assigning a new value to this attribute.
- property rating_allowed: bool
A boolean representing whether the listener can currently rate the song.
- property rating_histogram: dict[str, int]
A dictionary representing the distribution of ratings given to the song by all listeners. For example:
>>> song.rating_histogram {'1.0': 4, '1.5': 4, '2.0': 6, ..., '4.5': 46, '5.0': 26}
- property rating_rank: int
The position of the album when albums on the channel are ranked by rating. The highest-rated album will have
rating_rank== 1.
- property request_rank: int
The position of the song when songs on the channel are ranked by how often they are requested. The most-requested song will have
rating_rank== 1.
- property sid: int
See
channel_id.
RainwaveCandidate
- class rainwaveclient.RainwaveCandidate(album: RainwaveAlbum, election: RainwaveElection, raw_info: dict)
A
RainwaveCandidateobject is a subclass ofRainwaveSongrepresenting a song that is a candidate in an election.- property is_request: bool
A boolean representing whether the candidate is a listener request or not.
- property requested_by: RainwaveListener
The
RainwaveListenerwho requested the candidate, if the candidate is a request.Noneotherwise.
RainwaveRequest
- class rainwaveclient.RainwaveRequest(album: RainwaveAlbum, raw_info: dict)
A
RainwaveRequestobject is a subclass ofRainwaveSongrepresenting a song that has been requested to play on the radio.- property requester: RainwaveListener
The
RainwaveListenerwho made the request.
RainwaveUserRequest
- class rainwaveclient.RainwaveUserRequest(album: RainwaveAlbum, raw_info: dict)
A
RainwaveUserRequestobject is a subclass ofRainwaveSongrepresenting a song in the authenticating listener’s requests queue.- property blocked: bool
Trueif the request is currently blocked. Seeblocked_by_albumandblocked_by_categoryto determine why the request is blocked.
- property blocked_by_album: bool
Trueif the request is currently blocked because a song from the same album is in an election.
RainwaveUserRequestQueue
- class rainwaveclient.RainwaveUserRequestQueue(channel: RainwaveChannel)
A
RainwaveUserRequestQueueis a list-like object that supports explicit reordering.- reorder(order: list[int]) None
Change the order of the requests in the queue.
- Parameters:
order (sequence) – the indices of the requests in the new order.
Example usage:
If you have four songs in your request queue, and you want to move the last song to the top of the queue:
>>> from rainwaveclient import RainwaveClient >>> rw = RainwaveClient(5049, 'abcde12345') >>> game = rw.channels[0] >>> rq = game.user_requests >>> rq.reorder([3, 0, 1, 2])
To randomly shuffle your request queue:
>>> import random >>> indices = list(range(len(game.user_requests))) >>> random.shuffle(indices) >>> rq.reorder(indices)
All indices must appear in
orderand each index must only appear once.
RainwaveSchedule
- class rainwaveclient.RainwaveSchedule(channel: RainwaveChannel, raw_info: dict)
A
RainwaveScheduleobject represents an event on a channel.Note
You should not instantiate an object of this class directly, but rather obtain one from
RainwaveChannel.schedule_current,RainwaveChannel.schedule_next, orRainwaveChannel.schedule_history.- property channel: RainwaveChannel
The
RainwaveChannelobject the event belongs to.
- property end: datetime
A datetime.datetime object representing the end time of the event. For future events, this should equal
start+length. For current and past events this should equalstart_actual+length.
- property length: int
The duration of the event in seconds. For future elections, this value is estimated by averaging the duration of all songs in the election.
RainwaveScheduleobjects also support len(schedule).
- property start: datetime
A datetime.datetime object representing the estimated start time of the event. This is only useful for future events. For current and past events, see
start_actual.
RainwaveElection
- class rainwaveclient.RainwaveElection(channel: RainwaveChannel, raw_info: dict)
A
RainwaveElectionobject is a subclass ofRainwaveScheduleand represents an election event on a channel.- property candidates: list[RainwaveCandidate]
A list of
RainwaveCandidateobjects in the election.
- property song: RainwaveCandidate
The first
RainwaveCandidateobject in the list of candidates. If theRainwaveElectionevent has already closed, this is the song that won the election.
- property songs: list[RainwaveCandidate]
See
candidates.
RainwaveOneTimePlay
- class rainwaveclient.RainwaveOneTimePlay(channel: RainwaveChannel, raw_info: dict)
A
RainwaveOneTimePlayobject is a subclass ofRainwaveScheduleand represents a song added directly to the timeline by a manager.- property song: RainwaveSong
The
RainwaveSongfor the event.
- property songs: list[RainwaveSong]
A list containing the
RainwaveSongfor the event.
RainwaveListener
- class rainwaveclient.RainwaveListener(channel: RainwaveChannel, raw_info: dict)
A
RainwaveListenerobject represents a radio listener.- channel: RainwaveChannel = None
The
RainwaveChannelthe listener belongs to.
- property losing_requests: int
The number of requests made by the listener that lost their election.
- property losing_votes: int
The number of votes the listeners has given to a song that lost an election.
RainwaveCategory
- class rainwaveclient.RainwaveCategory(channel: RainwaveChannel, category_id: int, name: str)