MediaServer: Ampache

  1. Ampache
  2. Setting up Ampache for Coherence
  3. Setting up Coherence for Ampache
    1. Configuration
    2. Examples
  4. Multicast routing
  5. Troubleshooting
    1. Tests from the command line
    2. Open Tickets for this backend



Ampache

Ampache is a web-based audio file manager. It's implemented using MySQL and PHP. It allows you to view, edit and play your audio files via webbrowser.

Together with Coherence it forms a powerful DLNA/UPnP MediaServer, distributing the maintained media database to other UPnP clients on the local network.

An Ampache release >= 3.4.0 is required.

Setting up Ampache for Coherence

1. To setup Ampache and have it running, there's an excellent guide for Ubuntu/Debian systems. The official wiki can be found at here.

2. First you need to create the Access Control List) (ACL). It's a good idea to do this before enabling it in the config file. So you don't accidentally lock yourself out. Login to Ampache to define ACL by going to Menu -> Admin -> Add ACL and add the following three ACLs. This example will allow on the whole 192.168.1.0/24 (192.168.1.1 to 254) to access Ampache. You should tailor the IP addresses and ranges to your needs. Please note for usage outside of this range (such as remote access through VPN) you will need to create additional ACLs for the Web Interface and Stream Access.

1)

Name: Interface Access for Clients
Start IP Address: 192.168.1.1
End IP Address: 192.168.1.254
User: All
Level: All
ACL Type: Web Interface
Key: (blank)

Then click "Create ACL"

2)

Name: Streaming Access for Clients
Start IP Address: 192.168.1.1
End IP Address: 192.168.1.254
User: All
Level: All
ACL Type: Stream Access
Key: (blank)

Then click "Create ACL"

3)

Name: All Users RPC ACL
Start IP Address: 192.168.1.1
End IP Address: 192.168.1.254
User: All
Level: All
ACL Type: RPC
Key: mypassword

Then click "Create ACL" and remember what you set for a password. This is what Coherence will use to talk with Ampache. After you are done creating the ACLs, logout and login again to make sure you have access. If not, set

access_control  = "false"

in the config file and login again and adjust your ACLs.

You can also (optionally) create a separate user account for Coherence to use. Just remember the Username and Password you created if you choose to use that.

3. Once that is done you need to turn on Access Control and XML RPC in Ampache. You need to edit the ampache.cfg.php in your /ampache/config directory and set access_control to true.

; Use Access List
; Toggle this on if you want ampache to pay attention to the access list
; and only allow streaming/downloading/xml-rpc from known hosts xml-rpc
; will not work without this on.
; NOTE: Default Behavior is DENY FROM ALL
; DEFAULT: false
;access_control  = "false"

Change the last line to:

access_control  = "true"

(Pay special attention to the removed comment semicolon ";" at the beginning of the line and change "false" to "true")

While you are in that file, also check if xml_rpc = "true". Because without that Coherence won't be able to speak to Ampache.

; Use XML-RPC
; Allow XML-RPC connections, if you don't want _any_ possibility of your
; catalog being streamed from another location comment this out
; DEFAULT: false
xml_rpc         = "true"

Setting up Coherence for Ampache

Configuration

The Ampache backend accepts these options:

name:
the name this backend should show up on your UPnP clients, defaults to Ampache
url:
the url to access your Apache’s XML-API
key
the password to access the XML-API
user
an optional user account that was defined for Coherence in Ampache
password
the password for the optional username. Not needed if you have not configured an optional username.
version
optional, to define a different UPnP device version for that backend

Examples

Old config file:

[[AmpacheStore]] 
    name = MyAmpache
    url = http://ampache-host/ampache/server/xml.server.php
    key = yourpassword

New config file:

<plugin active="yes">
  <url>ampache/ampache/server/xml.server.php</url>
  <backend>AmpacheStore</backend>
  <name>Ampache</name>
  <key>llama</key>
  <user>optional-username</user>
  <password>password-for-username</password>
</plugin>

Remember that the <user> and <password> are only if you created a separate user account for Coherence to use in Ampache.

Python code:

coherence.add_plugin('AmpacheStore',
                     name='MyAmpache',
                     url='http://ampache-host/ampache/server/xml.server.php',
                     key='yourpassword')

DBus:

coherence_service = dbus.SessionBus().get_object('org.Coherence','/org/Coherence')
coherence_service.add_plugin('AmpacheStore',
                             {'name':'MyAmpache,
                              'url'='http://ampache-host/ampache/server/xml.server.php',
                              'key'='yourpassword'},
                             dbus_interface='org.Coherence',
                             reply_handler=add_plugin_callback,
                             error_handler=error_callback)

Commandline:

  coherence --plugin=backend:AmpacheStore,url:http://ampache-host/ampache/server/xml.server.php,key:yourpassword

Multicast routing

You must setup a multicast route for UPnP messages, in this example with eth0 as the interface you want them to travel over.

route add -net 239.0.0.0 netmask 255.0.0.0 eth0

Troubleshooting

Tests from the command line

To see if Coherence can connect to Ampache, run the following command. Be sure to change "ampache-host" to your Ampache host (either IP or DNS name) and add your RPC key after "key:"

coherence --plugin=backend:AmpacheStore,url:http://ampache-host/ampache/server/xml.server.php,key:YOURPASS_FROM_RPC_ACL

Then you should see something that resembles the following:

Coherence UPnP framework version 0.5.8 starting... (coherence/base.py:251)
WARN  webserver                   Oct 22 09:31:44  WebServer on port 59615 ready (coherence/base.py:106)
WARN  mediaserver                 Oct 22 09:31:45  Ampache MediaServer (Ampache storage) activated (coherence/upnp/devices/media_server.py:521)

That shows that Coherence has successfully connected to Ampache. You may also want to turn debugging on in Ampache by editing the config file:

; Debug
; If this is enabled Ampache will get really chatty
; warning this can crash browser during catalog builds due to
; the amount of text that is dumped out this will also cause
; ampache to write to the log file
; DEFAULT: false
;debug = "false"

Change the last line to:

debug = "true"

And you also want to set a log path:

; Path to Log File
; This defines where you want ampache to log events to
; this will only happen if debug is turned on. Do not
; include trailing slash. You will need to make sure that
; your HTTP server has write access to the specified directory
; DEFAULT: NULL
log_path = "/usr/local/www/ampache/log"

(Set the full path without trailing "/" and make sure your web server has write permissions to it doing chmod 777 to the file.)

Another way to turn on debugging for the Cohernece Ampache backend is to use

COHERENCE_DEBUG=ampache_store:4 coherence  
--plugin=backend:AmpacheStore,url:http://ampache-host/ampache/server/xml.server.php,key:yourpassword

to start Coherence.

Open Tickets for this backend

#291
Coherence doesn't handle Ampache links when using non standard port (8080)
#294
Add "tag" (Genre) support for Ampache backend