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.

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.getRandomSongs(size=2)
# We'll just pretty print the results we got to the terminal
print(songs[0].to_dict())

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.

Right now, only plain old dictionary structures are returned.

I may choose to do any of the following things on the original author's TODO list:

  • Lazy access of members (the song objects aren't created until you want to do something with them) However, I want to try and use the presented API first.

TODO

In the future, I would like to make this a little more "pythonic" and add some classes to wrap up the data returned from the server. Right now, the data is just returned in the form of a dict, but I would like to have actual Song, Album, Folder, etc. classes instead, or at least an alternative. For now, it works.

NOTE: I've noticed a wart with the upstream Subsonic API wherein any of the Connection methods that would normally return a list of dictionary elements (getPlaylists() for example), will only return a dictionary if there is a single return element. I plan on changing this in py-sonic so that any methods of that nature will always return a list, even if there is only a single dict in the list.

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-5.0.0.tar.gz (39.3 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-5.0.0-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file py-opensonic-5.0.0.tar.gz.

File metadata

  • Download URL: py-opensonic-5.0.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for py-opensonic-5.0.0.tar.gz
Algorithm Hash digest
SHA256 f919757f0bb35fcab0b17e2685eed2d7c72c60c31bfcd00362dda0afb7da1607
MD5 2fd75343d2c6701410099dd3b84ba2ec
BLAKE2b-256 25bb078fdbf92251f200670a235ffadc75acdc255ec710af5321b892ebfbfaaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_opensonic-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 44.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for py_opensonic-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68b54b2ab4805242df4f266691d87aecf6b8b9a7f0c2d0387b1c296a5b327b10
MD5 e25d007b8eece2dbb96bb626745ee97e
BLAKE2b-256 84752301d6ebb2db48c8e507f36aab8dfea50265b1ef23f8ba908dab4a84ab9c

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