Rhythmbox plugin. Get one number limited of songs

101 Views Asked by At

Get all songs:

for row in self.shell.props.library_source.props.base_query_model:
    print(row[0].get_string(RB.RhythmDBPropType.TITLE))

I need get only 10 songs (for example).

First try:

self.shell.props.library_source.props.base_query_model.set_property("limit-value", GLib.Variant("n", 10))
for row in self.shell.props.library_source.props.base_query_model:
    print(row[0].get_string(RB.RhythmDBPropType.TITLE))

Result:

Warning: g_object_set_property: construct property "limit-value" for object 'RhythmDBQueryModel' can't be set after construction
  self.shell.props.library_source.props.base_query_model.set_property("limit-value", GLib.Variant("n", 10))

Second try: I do not know how to set the limit value because try with GENRE

db = self.shell.props.db
query_model = RB.RhythmDBQueryModel.new_empty(db)
query = GLib.PtrArray()
db.query_append_params(query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.GENRE, "Salsa")

db.do_full_query_parsed(query_model, query)

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

Result: Rhythmbox closed. Error detailed in: How do I query for data in Rhythmbox

0

There are 0 best solutions below