Mopidy Discourse

[Announcement] Mopidy JSON/RPC Client for Python

Hi!

I have published on github (https://github.com/ismailof/mopidy-json-client) a python module to ease the access to Mopidy Core functionality from outside mopidy environment itself.

It uses websocket-client (https://pypi.python.org/pypi/websocket-client/) to connect to the Mopidy websocket interface. The module offers two main classes (client and listener), from which it is fairly simple for any other client to access to this functionality.

The reason behind this is that I’m starting a new media player project on a RPi which uses Mopidy as the music core. I plan to make a GUI Interface built on Kivy (python) and as a first step I needed a suitable way to communicate with Mopidy, listen to events, etc. I looked for any possible but I couldn’t find anything suitable, so I made one on my own.

I’m quite new to python coding, and a lot of work remains for this to be stable. For example I need to add robustness and server error handling, but it mainly works. I think it can help some other projects I’ve read on the forum which need simple communication to the mopidy server. As example of usage, there is a demo.py file included, which implements a simple CLI interface to mopidy.

2 Likes

Cool! I have for a long time had this on my list of planned projects. Myself, I intended to go for a Python 3 only client, building it on top of asyncio maybe with the websockets library.

I haven’t looked too closely on your project yet, but I hope that you’ve seen the Mopidy.js project which does the same thing for JavaScript. There lots of client devs already using that API, so keeping close to the Mopidy.js API could be great for adoption.

As for experience with Python, if you make sure that the code passes the flake8 linter without any warnings, it’ll be a lot more friendly to eyes used to Python code. Simply pip install flake8 and run flake8 . in the project repo.