GSoC Updates: ownCloud music Ampache API15 Jul 2016 | GNOME GSoC
Continuing from the grilo owncloud plugin last month, I’ve been working towards integrating the source with GNOME Music. In order to minimize the network requests, we’ve decided to cache the results in a local database. This would also improve user experience since cached results would populate relatively faster in the UI. Victor Toso suggested I look into GOM for implementing the cache and querying the data. My initial thought was to use raw SQL queries to query an sqlite database but this abstraction would help indeed.
While implementing the cache it’s important to consider when we decide to update it. The grilo plugin depends on the ownCloud music app which exposes an Ampache API for the music collection stored remotely. There are two cases to consider if the cache should be updated
- The music collection has been updated, i.e. some new files have been added to the collection or the metadata of the existing ones have changed
- The Ampache session is valid only for a fixed amount of time. In this scenario, we must update the cache in regular intervals to that the path to tracks remain valid
The Ampache API spec does indeed have an endpoint that can help with both the cases. The handshake endpoint returns an XML similar to
<root> <auth>AUTHENTICATION TOKEN</auth> <version>APIVERSION</version> <update>Last Update ISO 8601 Date</update> <add>Last Add ISO 8601 Date</add> <clean>Last Clean ISO 8601 Date</clean> <songs>Total # of Songs</songs> <artists>Total # of Artists</artists> <albums>Total # of Albums</albums> <tags>Total # of Tags</tags> <session_expire>Session Expire ISO 8601 Date</session_expire> <videos>Total # of Videos</videos> </root>
The update tag can certainly be used to check if there have been any updates and update the cache if so. Unfortunately, the current implementation in ownCloud music doesn’t conform to the spec rigidly and both the update and add tags just return the current time.
Lately, I’ve been working on improving the Ampache API implementation in ownCloud music. Morris Jobke has been occupied lately with other exciting projects and has been kind enough to grant me commit permissions on the music app. Thomas Pulzer’s patches for music have have also helped in the goal to achieve better spec compatibility. While the API is still not completely compliant with the Ampache XML-API spec yet, I think I’d be able to proceed with the cache implementation once PR #514 which deals with update and add time, gets merged :)
Until then, stay tuned for more updates!