pythongiorhythmbox

How do I query for data in Rhythmbox


I'm using ubuntu 12.04 and I'm trying to write a python plugin to query the Rhythmbox database. The Rhythmbox version is v2.96 but this issue also occurs with v2.97 as well. When I do a python query, Ubuntu crashes with a segmentation fault.

I need to confirm the following is correct and if I've found a bug specific to Ubuntu or if I've misunderstood how to correctly query. If anyone else using another distro can confirm - this would be most welcome.

I've filed a bug report on bugzilla with regards to the segmentation fault. However, my question is not strictly about this - its specifically trying to confirm the correct python code to query for data.

Thus my question: is the code snippet below correct to query the Rhythmbox database or do I need to install an additional package to enable querying.

Steps:

  1. Enable the python console plugin
  2. type (or copy and paste line by line the following)

from gi.repository import RB, GLib

db = shell.props.db
query_model = RB.RhythmDBQueryModel.new_empty(db)
query = GLib.PtrArray()

db.query_append_params( query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.ARTIST, 'some artist name' )
db.query_append_params( query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.TITLE, 'some song name' )   

db.do_full_query_parsed(query_model, query)

for row in query_model:
    print row[0].get_string( RB.RhythmDBPropType.ARTIST )
    print row[0].get_string( RB.RhythmDBPropType.TITLE )

If ubuntu 12.04 when I type this line, Ubuntu crashes with a segmentation fault

db.query_append_params( query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.ARTIST, 'some artist name' )

Thus, have I actually used the first parameter in the call correctly - the Query Pointer Array (PtrArray) - or is my query function parameters incorrect?


Solution

  • and the answer is...

    Well, this issue is indeed a bug - but to answer my own question,

    yes the syntax to query for data in Rhythmbox is as correctly stated in the question.

    and there is a however...

    Querying for data only works for 64bit linux.

    Yes really - I have been testing 32bit live-cd's of Fedora 17 as well as LMDE. Both exhibit the same segmentation fault issue as Ubuntu 12.04.

    The common factor is that I was testing Ubuntu 12.04/Fedora 17 and LMDE in their 32bit incarnations.

    Testing all three in their 64bit variants works as expected.

    The 32bit issue is a bug - and has been reported on bugzilla - but the question as posed has been answered.

    Thanks.