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).
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)
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)
Untar the source into your directory of choice. The source contains changes to the BRisa framework, which is bundled with it.
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)
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
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.
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).
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
\\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
after move "The" after the band name
remove (default) remove "The" from the band name
The initial run of scan will create your database. Subsequent runs to update the same database use exactly the same command. The initial scan run will read all files, subsequent runs will only read files that are new/deleted or have changed. You can also run subsequent runs in higher level directories (for instance if you have just ripped a CD or changes an album's tags) - this will only scan/affect a subset of the full library (e.g. /mnt/nas/Linkin Park/Meteora
The -wSonospy parameter to serve the files scanned above is:
-wSonospy=<name>,sonos.db
where
There are several ini file settings (in sonospy/sonospy/pycpoint.ini) that influence how the clone displays things on browsing (these are in the [INI] section of that file):
use_albumartist=Y (or N) works like the Sonos "use albumartist"
show_duplicates=Y (or N) instructs the clone whether or not to show duplicate tracks/albums
album_identification=album,artist (or album) instructs the clone how to group albums of the same
name. "album/artist" displays separate albums per artist, whereas
"album" groups artists under one album
The clone also supports transcoding. If you attempt to play an mp2 file, the clone will transcode it on-the-fly to mp3 and serve it as mp3 to Sonos. If you attempt to play a FLAC file that is >16 bit or
48k sample rate, the clone will transcode it on-the-fly and serve is as 16/48 to Sonos. If you attempt tp play a 6 channel FLAC file, the clone will transcode it to 2 channel.
The clone also supports streaming of PC sound to Sonos. If you create a file
Transcoding and streaming PC sound require you to have lame (for mp2), sox (for FLAC) and parec (for PC sound) installed and available on the command path.
Currently the web browser has some experimental views (Gallery and Flow). In order to utilise those views you need to bear the following in mind:
) To populate the cache of album entries for Gallery and Flow views, you need to select a server and browse albums on it. ) To populate the cache of album art, after populating the cache of album entries you need to select Cache Images. *) To be able to select tracks from the albums displayed in the Gallery and Flow views, you need to select the server containing those albums before entering the view.
Login/register/lost password are not yet implemented.
The control point can be configured via its ini file (pycpoint.ini), held in the sonospy directory within the directory that you installed the source code. There are example settings within the ini file.
To add UPnP to WMP server mappings in the pycpoint.ini file, you need to:
---- add more detail about mappings ----
1) Add
2) Add sections to the ini for:
[
To add IR over IP mappings for amplifier volume control in the pycpoint.ini file, you need to:
---- add more detail about IR ----
1) Add an [IP Volume] section. 2) Add file mappings for volume up, down, mute and unmute for the friendly name(s) of the ZP(s) you wish to control. Entries are: