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.netlify.app/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.netlify.app (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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_opensonic-10.1.0.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_opensonic-10.1.0-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file py_opensonic-10.1.0.tar.gz.

File metadata

  • Download URL: py_opensonic-10.1.0.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for py_opensonic-10.1.0.tar.gz
Algorithm Hash digest
SHA256 496f403811e3ad3bf2acc30c491b637889b5a79734a8dc3ae9c3e52d79242d8f
MD5 f63be8c9d7e8e8a69f5849e2c1f1edb1
BLAKE2b-256 745169f2d2146c1d3eaf3a0285a956fc7337ab5680f85fada7b343c386d7ac10

See more details on using hashes here.

File details

Details for the file py_opensonic-10.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_opensonic-10.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for py_opensonic-10.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2836727efc665261a59d6305c75d95faa01626be3e787f701df997e53b16cd0
MD5 d2bbe12d80b1eeec83c6ead1ea02802c
BLAKE2b-256 bf95c186bdc57b7bcb47f268eb436939d0d018c423aa678ee91e647e18898c0c

See more details on using hashes here.

Release history Release notifications | RSS feed

10.4.0

2 files

10.3.0

2 files

10.2.1

2 files

10.2.0

2 files

This release

10.1.0 This release

2 files

10.0.0

2 files

9.2.0

2 files

9.1.0

2 files

9.0.1

2 files

9.0.0

2 files

8.1.3

2 files

8.1.2

2 files

8.1.1

2 files

8.1.0

2 files

8.0.1

2 files

7.0.4

2 files

7.0.3

2 files

7.0.2

2 files

7.0.1

2 files

7.0.0

2 files

6.0.2

2 files

6.0.1

2 files

6.0.0

2 files

5.3.1

2 files

5.3.0

2 files

5.2.1

2 files

5.2.0

2 files

5.1.1

2 files

5.1.0

2 files

5.0.5

2 files

5.0.4

2 files

5.0.3

2 files

5.0.1

2 files

5.0.0

2 files

4.0.7

2 files

4.0.6

2 files

4.0.5

2 files

4.0.3

2 files

4.0.2

2 files

4.0.1

2 files

4.0.0

2 files

3.0.7

2 files

3.0.6

2 files

3.0.5

2 files

3.0.3

2 files

3.0.2

2 files

3.0.0

2 files

2.0.1

2 files

2.0.0

2 files

1.0.2

2 files

1.0.0

2 files

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