Gaurav's Blog Musings on Programming

GSoC Updates: Plugging in the grilo owncloud plugin

My GSoC Project has materialized quite a bit since the last blog post. In the previous blog post I discussed implementing a cache for persisting the query results from the owncloud grilo plugin. However, after some discussions with Felipe, we decided it’s better to proceed without the cache for now.

The application until recently supported only Tracker as a source for media collection to populate the various views. After adding the query method to the owncloud grilo plugin, “plugging” it in GNOME Music has been really convenient.

The screenshots below show how remote media integrates seamlessly in the UI Album Songs View Artist View Songs View

While the playback works smoothly, I have encountered issues in seeking the tracks which is because the ownCloud music app doesn’t support the Range Header. A fix for it is a WIP and the issue should hopefully be sorted out in the coming week. With the query operation implemented, all that remains is support for search, which would allow the users to search their owncloud music collection.


The last week has been uneventful to say the least, particularly because it crashed all my hopes of attending GUADEC this year :( Heads up for those who’re applying for a Schengen Visa (Germany in particular) - make sure the photograph in your Passport is of good quality and ‘according to Schengen specifications’. I hope you guys have a good one this year and hopefully I’ll get a chance to attend the conference in the coming years :)

GSoC Updates: ownCloud music Ampache API

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

  <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>

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!

Grilo Plugins: ownCloud source

This week concluded weeks 3-4 of my GSoC project on adding ownCloud support to GNOME Music. Carrying on from my previous post, after adding support for ownCloud Music in GOA, I’ve been working on implementing a grilo plugin for the same.

To a task that seemed fairly straightforward with ownCloud Music’s implementation of the Ampache API, it suffered a bit of a roadblock since the app didn’t support the Album Artist ID3 tag (TPE2). This was crucial since the grilo plugin would be used by gnome-music at a later stage which uses the tag quite often.

There seems to be a bit of an ambiguity around the usage of the Album Artist tag. After digging around a bit, Michael Koby’s article on the topic makes it pretty clear. Adding support for the tag in ownCloud music required changing the schema and rewriting a fair bit of the queries. On the frontend of ownCloud’s music app, the albums will now be grouped by Album Artists instead of Track Artists which makes finding albums easier at one place in case they have tracks by different artists. The code for the above changes is being reviewed and can be accessed at GitHub.

Grouping Albums by Album Artist

Moving on, I was excited to write the grilo plugin in LUA. While I didn’t have much experience with the language, it didn’t feel strange at all perhaps because of my familiarity with Python. Kudos to Tyler Neylon’s screencast on working with the C API and the LUA stack in particular, which immensely helped me in writing some wrapper methods in C.

grilo-test-api showing the ownCloud source in action

Shout out to Bastien Nocera and Victor Toso who helped me all along during the development of the plugin and the required wrapper methods :) Next up, working on queries and moving over to the gnome-music side of things!

GNOME Online Accounts: Extending the ownCloud Provider

GNOME Online Accounts (GOA) has had support for ownCloud since quite some time. As a part of my project, I’ve been extending the ownCloud provider to add support for the Music feature.

GOA ownCloud

ownCloud provides a neat music app which allows users to access their music collection, while at the same time, it provides application developers with a rich API. The Ampache API rightly supports authentication and requires a password to be generated which is distinct from the user’s ownCloud credentials.

ownCloud Music Generate Password

While one can manually generate a password for the Ampache API via ownCloud’s settings, we decided it would be better to automatically generate the password when the user sets up the ownCloud account on GOA for the first time, and store it along with the ownCloud credentials in the Keyring. This meant extending ownCloud’s music app to provide some endpoints for password generation (to be covered in detail in another post).

Since ownCloud’s music app isn’t a part of ownCloud core, there were a few special cases that needed attention:

  • If the music app isn’t enabled on ownCloud’s end, the music feature is disabled.
  • In case the music app is disabled after the the password has been generated, EnsureCredentials would return failure.
  • A new method, RetryFeature will be available on the Account Interface which would allow the user to enable Music feature at a later time, in case ownCloud’s music app was not available initially.

The code for the above mentioned features is being reviewed and should hopefully be merged soon :)

What’s next?

Now that GOA supports storing the Ampache API credentials, we can retrieve and use them for the implementation of a grilo plugin. The Lua-factory plugin allows writing Grilo sources in LUA and I’ve recently extended it to support password based GOA accounts. In the coming week, I plan to work on the lua plugin for ownCloud/Ampache.

GSoC 2016 Introduction

Hi everyone! My name’s Gaurav Narula and I’m a third year undergrad student at BITS Pilani K.K. Birla Goa Campus. I’m pursuing a double major in Economics and Computer Science.

I’ve been using GNOME since a long time - the first instance I recall is when I got a Live CD of Ubuntu 6.10 via ShipIt. GNOME’s evolved a lot since then and has still remained my go to DE over all these years. I started with GTK+ development rather recently, with some contributions to gnome-mpv, a GTK+ frontend for the MPV Media Player around October 2015.

A few months later, I stumbled upon GNOME Music while searching for a new music player and it soon became my default music player. I then decided to become more involved with the project. I dived into its source and tried to fix some small bugs around February with assistance from Felipe Borges, Victor Toso and Carlos Garnacho all along.

Coming to my project, GNOME Music currently only allows access to one’s local music collection. Over the past few years, GNOME apps have integrated well with ownCloud to sync and retrieve files stored remotely and Music shouldn’t be an exception to the same :) The goal of the project is to allow playing and searching ones music collection over ownCloud. ownCloud’s music app exposes an Ampache API which will be used to develop a Grilo Plugin to allow remote media discovery in Music. Victor’s work in GSoC 2013 would allow writing the plugin in LUA and will be of great help to quickly get things working. Recent changes in ownCloud’s music App with help from Moris Jobke have set the stage and I can’t wait to begin work!

I’m fortunate to have Felipe Borges (GNOME) and Lukas Reschke (ownCloud) as my mentors along with many other people from both the organisations who’ve helped me all along. Looking forward to an exciting summer ahead! Stay tuned for more updates :)