Skip to main content

A python wrapper library for the Open Subsonic REST API. https://opensubsonic.netlify.app/

Project description

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 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

Adding the async impl along with a sync one was not done in the most pythonic way and should be revisited to avoid some of the code duplication. I will eventually get to it, but patches welcome!

Project details


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-8.1.1.tar.gz (54.9 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-8.1.1-py3-none-any.whl (56.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py_opensonic-8.1.1.tar.gz
Algorithm Hash digest
SHA256 bf187ccbcaf48bf2b907e63b266d9270012e2f68852b828339e12b4132c04a87
MD5 fb8ce949e34ae5ba359f246d1df8a36f
BLAKE2b-256 8fbead547998c0d21754bc900bea2edae9f905dd8a5c118fdeda615f152d4c30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_opensonic-8.1.1-py3-none-any.whl
  • Upload date:
  • Size: 56.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-8.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40365ad1b552f98ef8e3a80866748e6db132a817b0f49757ea0c33f4ab5adb4e
MD5 60ddefa30b40a666b0f3950b1167fe0d
BLAKE2b-256 e437977572d3d8815105a612779af3be99270ccdffc50a3ba78ee983c301c452

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page