Re: [Rhythmbox-devel] Magnatune catalog/purchasing plugin

Brilliant, thank you! Looking at the ipod source definitely helped me
better understand what I need to do.

On Thu, 2006-15-06 at 14:13 +1000, Jonathan Matthew wrote: 
> On Wed, Jun 14, 2006 at 02:40:13PM -0700, Adam Zimmerman wrote:
> > 
> > - How do I add songs to my source? generic-player seems to get its own
> > rhythmdb instance or something, and then call db.add_uri on the song
> > (directory in that case). I tried this in the python console, and
> > succeeded in adding a song to the library, so it seems right, just that
> > I need a separate db (or do I?).
> You don't need a separate db - there can only be one instance of the
> database at the moment.  What everything does at the moment is retrieve
> a reference to the db object from the shell object.  It looks like
> you're already doing this correctly.

OK, good to know. So does rhythmbox decide what source to show an entry
in by its entry-type?

> > 
> > - Is there a way to associate other data with an entry (such as the
> > album sku)? add_uri only takes the uri of the file as an argument.
> I don't think we have a way to do that from python.  In C, you specify
> an extra amount of space to allocate with each entry of your given type,
> then use rhythmdb_entry_get_type_data() to get a pointer to it.

This is only useful once I start doing purchasing, so I'll leave it for

> > - Is there a way to manually set the metadata for a track, so rhythmbox
> > doesn't have to hit every mp3 file on magnatune?
> Basically, look at how the ipod source works (add_ipod_song_to_db() in
> rb-ipod-source.c).  It registers an entry type, then for each entry in
> the ipod's database, it creates an entry (rhythmdb_entry_new), sets
> various properties (rhythmdb_entry_set), then commits the changes
> (rhythmdb_commit).  You may have some problems trying to do this in
> python, though, since I don't think anyone has tried it before.
> I'll have a look at this and the entry type data thing later on and post
> more information.  I don't think we'll be making any changes until we
> release 0.9.5, which should be fairly soon.

OK, this is the part I still need some help on. From what you're saying,
I gather that my source needs to create its own entry type, right? Right
now I'm doing this:

def activate(self, shell):
	db = shell.get_property("db")
	model = db.query_model_new_empty()
	entry_type = rhythmdb.rhythmdb_entry_register_type("")
	self.source = (MagnatuneSource, shell=shell,
name=_("Magnatune"), query_model=model)
	shell.register_entry_type_for_source(self.source, entry_type)
	shell.append_source(self.source, None)
Do I also need to do something when creating self.source?
And then in the endElement method of the xml handler, I have:

def endElement(self, name):
	if name == "Track":
		print "Adding: %s - %s" % (self._track['artist'],
		# add the track to the source
		entry = self._db.entry_new(entry_type, self._track['url']) # how do we
get the entry type for the source?
		self._db.entry_set_uninserted(entry, rhythmdb.PROP_ARTIST,
		self._db.entry_set_uninserted(entry, rhythmdb.PROP_ALBUM,
		self._db.entry_set_uninserted(entry, rhythmdb.PROP_TITLE,
		# etc., etc.
		self._track = {}
	elif name == "AllSongs":
		pass # end of the file
		self._track[name] = self._text

The problem is, I'm not sure how to get the entry_type argument for the
call to entry_new. I've tried various things, and it keeps saying:
TypeError: type should be a RhythmDBEntryType_

Thanks in advance.

Adam Zimmerman <adam_zimmerman sfu ca>

ALWAYS      -
BUILDS      -

"People everywhere enjoy believing things that they know are
 not true.  It spares them the ordeal of thinking for themselves
 and taking responsibility for what they know."
         [Brook Atkinson, "Once Around the Sun"]

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]