Welcome to Listen’s documentation!

About

Listen is a fully asynchronous wrapper around the Listen.moe API that’s built upon the websockets lib and aiohttp. The official supported versions of Python for this library are anything onwards from 3.5

Installation

$ pip install git+https://github.com/GetRektByMe/Listen.git

Master branch should always work, you can install dev branches by choice. These may be broken.

Contents

Full Listen API reference

Note

Logging should be implemented on your end

Note

A feature that will get previous song names may be added at some point

Find out your version

listen.__version__
A string that represents the version of Listen you're using.

Client

class listen.client.Client(loop: asyncio.base_events.BaseEventLoop = None)[source]

Client class to interface with listen.moe’s API

create_websocket_connection(authenticate: bool = False)[source]

This function is a coroutine

Creates a websocket connection to Listen.moe’s socket API

Parameters:authenticate (bool) – Boolean that decides if the authentication to the API is done
Return type:None
favorite_toggle(song_id: int)[source]

This function is a coroutine

Either favourites or unfavourites a song based on if it’s favourited already

Parameters:song_id (int) – The id of the song you want to favourite
Return type:bool
get_favorites()[source]

This function is a coroutine

Get all favourites from the current logged in user

Return type:listen.objects.Song
get_info()[source]

This function is a coroutine

Get a user object that is associated with the logged in user

Return type:listen.objects.User
get_token(username: str, password: str)[source]

This function is a coroutine

Get user token for the account you’re using to sign in

Parameters:
  • username (str) – The username of the account you’re getting the token for
  • password (str) – The password of the account you’re getting the token for
Return type:

str

make_request(song_id: int)[source]

This function is a coroutine

Requests a song for queueing

Parameters:song_id (int) – The id of the song you want to request
Return type:bool
register_handler(handler)[source]

Registers a function handler to allow you to do something with the socket API data

Parameters:handler (function) – A function that takes a dictionary that contains Listen.moe’s API data
run()[source]

Start the connection to the socket API

DataClasses

Note

These are not for creating yourself, they are handed to you from the library backend

class listen.Song(id: int, artist: str, title: str, anime: str, enabled: bool)[source]
class listen.User(id: int, username: str)[source]

Exceptions

Note

listen.Client.start() throws RuntimeError if the absence of a handler is spotted.

exception listen.KanaError[source]
exception listen.ListenError[source]

Examples of Listen API usage

Coming when people actually use this library

FAQ

Coming when people actually use this library