Skip to main content

py-opensonic

A python library for interacting with an Open Subsonic API implementation. This started its life as the py-sonic library. I have tested with Gonic (and continue to do so against each stable docker release). Please open issues if you discover problems with other implementations.

As of 10.0.0 we have stopped using unasync and instead the sychronous Connection object is a thin wrapper around the AsyncConnection that runs an event loop and makes async method calls for the user.

As of 9.0.0 we use unasync to generate the synchronous Connection class from the Async one. This will stop us from having to maintain duplicate code in the two classes. If you submit a PR that changes the Async class, please be sure to run scripts/gen_sync.py and add the resulting changes to the synchronous class as well.

Any PRs that change the synchronous class by hand or without updating the asynchronous one and/or the gen_sync.py script will be immediately closed.

As of 8.0.0 this library now offers an AsyncConnection object that uses aiohttp for all its http requests. It does not create an event loop so is usable inside any application built on asyncio. The Connection object will continue to use synchronous IO and will remain for backward compatibility.

INSTALL

Installation is fairly simple. Just do the standard install as root:

tar -xvzf py-opensonic-*.tar.gz
cd py-opensonic-*
python setup.py install

You can also install directly using pip or easy_install

pip install py-opensonic

USAGE

This library follows the REST API almost exactly (for now). If you follow the documentation on https://opensubsonic.github.io/docs/ or you do a:

pydoc libopensonic.connection

The py-sonic original author has added documentation at http://stuffivelearned.org/doku.php?id=programming:python:py-sonic

BASIC TUTORIAL

This is about as basic as it gets. We are just going to set up the connection and then get a couple of random songs.

#!/usr/bin/env python

import libopensonic

# We pass in the base url, the username, password, and port number
# Be sure to use https:// if this is an ssl connection!
conn = libopensonic.Connection('https://music.example.com' , 'myuser' , 
    'secretpass' , port=443)
# Let's get 2 completely random songs
songs = conn.get_random_songs(size=2)
# We'll just pretty print the results we got to the terminal
print(songs[0])
print(songs[1])

As you can see, it's really pretty simple. If you use the documentation provided in the library:

pydoc libopensonic.connection

or the api docs on opensubsonic.github.io (listed above), you should be able to make use of your server without too much trouble.

Async/Sync Cohabitation

As of 9.0.0 we use unasync to generate the synchronous Connection class from the Async one. This will stop us from having to maintain duplicate code in the two classes. If you submit a PR that changes the Async class, please be sure to run scripts/gen_sync.py and add the resulting changes to the synchronous class as well.

Any PRs that change the synchronous class by hand or without updating the asynchronous one and/or the gen_sync.py script will be immediately closed.

pytest

There are now pytest unit tests which are configured to run on any new PR, these tests must be passing to merge. Please add tests to any fixes or new features.

Metadata

Release files for py-opensonic 11.0.0

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

Source distribution (sdist)

Source distribution for py-opensonic 11.0.0
File Size Uploaded Provenance Actions
py_opensonic-11.0.0.tar.gz 58.4 kB Without provenance Details for py_opensonic-11.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-opensonic 11.0.0
File Interpreter ABI Platform Actions
py_opensonic-11.0.0-py3-none-any.whl Python 3 none any Details for py_opensonic-11.0.0-py3-none-any.whl

Total release size: 104.5 kB

Release files / py_opensonic-11.0.0.tar.gz

Download URL py_opensonic-11.0.0.tar.gz
Size 58.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ce21f6c55bc36c99ec3b0d70179fcdc658fc26360fbcf243536298d0e7d12c8a
BLAKE2b-256 checksum
How to use checksums
2f0a2900e36785b4a92a7d7a7f584a032ee86e6b8b3dedc5805774bbc2d439d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / py_opensonic-11.0.0-py3-none-any.whl

Download URL py_opensonic-11.0.0-py3-none-any.whl
Size 46.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b663ae100a8a3d4aeea284f58b608c9ddf14785621c8b3d216c5ceedb47439c
BLAKE2b-256 checksum
How to use checksums
d0b87315aef3d8df166005a3c22f36a64cde6090dfbb27e24069e329edf26ea9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for py-opensonic 11.0.0

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.

Release history Release notifications | RSS feed

This release

11.0.0 This release

2 release files No provenance

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