SkillAgentSearch skills...

Sonospy

Sonospy is a UPnP control point and Windows Media proxy for the Sonos multi-room audio system.

Install / Use

/learn @henkelis/Sonospy
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

sonospy

Developed using Wingware Python IDE - http://wingware.com

Python Control Point is a UPnP control point for audio files and streams.

It is built on top of the BRisa UPnP framework, with extensions added for Sonos ZonePlayers and the content they can serve/render.

It can be run in proxy only mode (no GUI).

Dependencies in this order (links correct at time of writing):

You will need to download the following dependencies. Installation instructions for them for your platform can be found on the link pages.

Python 2.6 or later (but not 3.0 and up) Linux: from your distro or get the source tarball from http://www.python.org/download/releases/2.6.4/ Mac: http://www.python.org/download/releases/2.6.4/ - select the Mac installer Windows: http://www.python.org/download/releases/2.6.4/ - select the windows installer (for Windows, remember to set the path environment variable so it can find Python)

To play files locally on the machine running pycpoint: gstreamer 0.10+ - http://gstreamer.freedesktop.org/download gmediarender-0.0.6 - http://gmrender.nongnu.org/#dl

To transcode file types on-the-fly that Sonos doesn't support lame (for converting mp2 to mp3) sox (for downsampling FLAC) parec (to send PC output to ZP)

Packages bundled with sonospy:

The following packages are bundled with sonospy (no need to download/install):

cherrypy: cherrypy WSGI server 3.1.2 (All platforms: http://www.cherrypy.org/wiki/CherryPyDownload)

python-brisa: python-brisa Framework 0.10.0 python-brisa Qt Reactor 0.10.0 (All platforms: http://brisa.garage.maemo.org/installation.html)

web2py (only needed if running the control point with a GUI (rather than just as a proxy server)): web2py 1.76.3+ (All platforms: http://www.web2py.com/examples/default/download)

Installation of pycpoint:

Untar the source into your directory of choice. The source contains changes to the BRisa framework, which is bundled with it.

Ports:

The following ports need to be open in the firewall on the machine you are running sonospy on. Most are standard UPnP/WMP ports, with additional ones for the BRisa framework, the proxy and IR control.

Note that you may need to open ports specific to other UPnP media servers too (if you are using them).

1900            UDP
2149            UDP     (current M-SEARCH send port so WMP is picked up)
2869            TCP
10243           TCP
10244-+n        TCP     (proxy internal WMP server, inc for multiple, can be changed in ini)
10280-10284     UDP
50101-50102     TCP     (control point and proxy, can be changed in ini)
65432           UDP     (if using IR control, can be changed in ini)

Run:

To start the UPnP controlpoint and the web server, run:

For linux:

    ./sonospy_web
    
For Windows:

    sonospy_web.cmd

from the directory you installed the source into. This will start the control point and web server in the background. Output from the control point will be written to pycpoint.log in the base directory, output from the web server to web2py.log.

To connect to the web server, open a web browser and enter the following URL:

http://<IP ADDRESS>:8000/sonospy/default/index

replacing <IP ADDRESS> with the IP address of the machine running the web server. If you are running the web browser on the same machine as the web server you can use localhost as the ip address.

In the browser you should see a GUI that allows selection and browsing of UPnP servers on the local network and selection of UPnP renderers on the same network to play content on.

The browser can also be started in mobile mode with a screen sized for use on mobile devices.

To start in mobile mode run:

http://<IP ADDRESS>:8000/sonospy/default/index?M=P

    or

http://<IP ADDRESS>:8000/sonospy/default/index?M=L

where P starts in portrait orientation and L starts in landscape orientation.


---- add more detail of mobile mode ------- ---- describe how to run on a mobile device

To start the UPnP controlpoint as a proxy only, run:

For linux:

    ./sonospy_proxy <parameters>
    
For Windows:

    -- todo --
    -- for now use the following --
    
    cd sonospy
    pythonw pycpoint.py -p <parameters>

from the directory you installed the source into.

Parameters can include:

-wSonospy=<name>,<database>[,<ini>]   implements an internal WMP server on port 10243 (note
                                      that won't work if WMP is using that port on that machine). 
                                      Multiple -wSonospy options can be used. Note that you need 
                                      to generate the database beforehand for this option to work
                                      (see "Internal WMP Database" below for further information)

-- todo --
-s

Example parameters:

-wSonospy=Music,sonos.sqlite    implements the internal WMP server, serving content described in
                                sonos.sqlite via a media server named Music (will show up on the
                                CR100/CR200/iTouch etc)

-wSonospy=Music,sonos.sqlite,index.ini    implements the internal WMP server, serving content described in
                                          sonos.sqlite via a media server named Music, with index settings
                                          read from index.ini

Example calls:

For linux:

    ./sonospy_proxy -wSonospy=Music,sonos.sqlite

    ./sonospy_proxy -wSonospy=Peter,peter.sqlite,peter.ini -wSonospy=Leanne,leanne.sqlite,leanne.ini
    
For Windows:

    -- todo --
    -- for now use the following --
    
    cd sonospy
    pythonw pycpoint.py -p -wSonospy=Music,sonos.sqlite

You can also use the parameters above with the web browser, so for example to start the control point with a local mediaserver proxied and available to both the web browser and Sonos controllers run:

For linux:

    ./sonospy_web -wSonospy=Music,sonos.sqlite
    
For Windows:

    -- todo --
    -- for now use the following --
    
    cd sonospy
    pythonw pycpoint.py -p -wSonospy=Music,sonos.sqlite
    cd ..
    pythonw web2py/web2py.py -L options.py

When running as a proxy only you will need a separate control point (e.g. the Sonos controller) to select and play tracks.

To stop the UPnP controlpoint and the web server (if running), run:

For linux:

    ./sonospy_stop
    
For Windows:

    -- todo --
    -- for now use the following --

    stop pythonw processes in task manager

This will stop the background processes.

Further command line options are available for pycpoint as below - you'll need to edit the script files or create your own command lines to use them:

-d                enables debug output (this will be verbose and slow down searching etc)

-m<module>        enables debug output for <module>

Note that you will have to initially run brisa-conf to set the error level to debug to see debug output. From the sonospy/sonospy directory run:

For linux:

    brisa-conf -s brisa -p logging DEBUG

For windows:

    python brisa-conf -s brisa -p logging DEBUG

There's a setconf.sh script in the tarball that you can edit and run if you manage to mess up the brisa section in the config (for Windows use setconf.cmd).

Internal WMP Database

Sonospy implements an internal WMP clone for serving content. The clone browses an sqlite database containing tag data, and presents that to Sonos controllers. You need to create the database by scanning you music files, then re-scan when changes have been made (tracks added or deleted, tags changed etc). A utility is provided to create and maintain databases. Scan reads all music files in a set of directories and extracts their tag data (this is stored in a database). This database is presented to Sonos controllers for browsing.

Scan supports multiple entry tags (so you can tag with multiple genres for instance). Multiple entries in a tag are separated with a semi-colon (;). Scan also supports multiple tags of the same name. Scan supports duplicate files in different directories (so you can have the same track in more than one place and each will be displayed on the Sonos controller (suffixed with a number).

To scan you music library for metadata tags, navigate to the sonospy/sonospy directory and run:

For linux:

    ./scan -d <database> <path-to-files>

For windows:

    python scan -d <database> <path-to-files>

Note that on Windows any backslashes in the <path-to-files> have to be duplicated, and any spaces preceded by a backslash, e.g.

\\NAS\music\some music folder

needs to be:

\\\\NAS\\music\\some\ music\ folder

Scan supports -q for quiet and -v for verbose output.

An example command to create a database named 'sonos.db' (in the sonospy/sonospy directory), reading music files from /mnt/nas (\NAS\music on windows) is:

For linux:

    ./scan -d sonos.db /mnt/nas

For windows:

    python scan -d sonos.db \\\\NAS\\music

It is possible to affect the default behaviour of scan by amending parameters in the scan.ini file.

To change the way "The" is handled in artist names while browsing (note the full artist name will be displayed when playing), change the setting of the "the_processing" parameter. Options are:

before      leave "The" before the band name
View on GitHub
GitHub Stars111
CategoryDevelopment
Updated3mo ago
Forks16

Languages

Python

Security Score

92/100

Audited on Dec 19, 2025

No findings