Skip to main content

License: GPL v2

Mopidy-Async-Client

Fork of Mopidy-json-client, but from scratch and async

Async Mopidy Client via JSON/RPC Websocket interface

Usage

mopidy-async-client provides a main class MopidyClient, which manages the connection and methods to the Mopidy Server.

import asyncio

from mopidy_async_client import MopidyClient


async def playback_started_handler(data):
    print(data)


async def all_events_handler(event, data):
    print(event, data)


async def main1():
    async with MopidyClient(url='ws://some_ip:6680/mopidy/ws') as mopidy:  # close connection explicit
        await mopidy.playback.play()


async def main2():
    mopidy = await MopidyClient().connect()
    mopidy.listener.bind('track_playback_started', playback_started_handler)
    mopidy.listener.bind('*', all_events_handler)

    # your app logic
    for i in range(10):
        await asyncio.sleep(5)
    # end your app logic

    await mopidy.disconnect()  # close connection implicit


asyncio.run(main1())
# or 
asyncio.run(main2())

Parse results

You can specify parse_results=True in MopidyClient and get Mopidy objects instead of json dictionaries. To do this, you need to install Mopidy locally (only for importing models)

async with MopidyClient(parse_results=True) as mopidy:
    res = await mopidy.tracklist.get_tracks()
    print(res)

>>> [Track(date='2020-01-01', length=392533, name='audio.mp3', uri='file:///home/svin/Music/audio.mp3')]
# instead of
>>> [{'__model__': 'Track', 'uri': 'file:///home/svin/Music/audio.mp3', 'name': 'audio.mp3', 'date': '2020-01-01', 'length': 392533}]

Installation

pip install mopidy-async-client

References

Metadata

Release files for mopidy-async-client 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mopidy-async-client 0.6.4
File Size Uploaded Provenance Actions
mopidy-async-client-0.6.4.tar.gz 18.4 kB Without provenance Details for mopidy-async-client-0.6.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mopidy-async-client 0.6.4
File Interpreter ABI Platform Actions
mopidy_async_client-0.6.4-py3-none-any.whl Python 3 none any Details for mopidy_async_client-0.6.4-py3-none-any.whl

Total release size: 36.4 kB

Release files / mopidy-async-client-0.6.4.tar.gz

Download URL mopidy-async-client-0.6.4.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0677d41ef9dff7b8fa5142b308d4bfa15b02b0f8a6398f9f37f24e60e87aaaac
BLAKE2b-256 checksum
How to use checksums
a21f413baad91f6b15d01b02b24b8fbc6c6d2259170e3f909408a1c6e3f219bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / mopidy_async_client-0.6.4-py3-none-any.whl

Download URL mopidy_async_client-0.6.4-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd7d36ab3245ddf0b3dd19bbb49fe276f50d066572ac8c4a2071741ba30eb984
BLAKE2b-256 checksum
How to use checksums
2a41b8c92733b9e7dc12d45ac7534ae186edc9d9f24a360acb5c918c9af44903
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Security for mopidy-async-client 0.6.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page