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



On Wed, Jun 14, 2006 at 02:40:13PM -0700, Adam Zimmerman wrote:
> Hi everyone,
> 
> After reading this[1] entry in the blog of Magnatune's founder, I
> figured I'd try to write a plugin for rhythmbox that did the same thing
> as an exercise. So, after a while, I realized that I have basically no
> idea how rhythmbox works, and the plugins I'm looking at for help
> (mostly generic-player, since it adds a source) are written in C, which
> I don't know.

I think the DAAP and iPod sources would be better to work from for what
you're doing, since they directly create their own rhythmdb entries
rather than importing from a filesystem.

> So I've got a couple of questions about python plugins/rhythmbox in
> general. I'd appreciate any help anyone could give me.
> 
> - 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.

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

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

> And some other questions related to purchasing (I'm going to try to get
> playback working first, so these are lower priority):
> 
> - I'm not quite sure how to allow the user to set options (such as email
> address, credit card info, etc.). Ideally I'd like to give the user the
> option of entering cc info every time (default) or saving it.

If your plugin provides an implementation of the 'create_configure_dialog'
method, rhythmbox will display the resulting dialog when you hit the
'configure' button on the plugin dialog.  You can (optionally) store the
information in gconf, under /apps/rhythmbox/plugins/<your-plugin>/.

Another option would be to override the 'impl_activate' method on the
source object, so the first time the user selects your source, you can
pop up a window asking for the information you need.

> - How do I add a context-menu action to an entry ("Buy this album")?

The entry view for your source will emit a show-popup signal when the
user right clicks (or hits the menu key, or whatever).  Your source
can attach a handler to that and show its popup.  I don't know much
about doing this in python.

> - Can I use track-transfer to transfer a bought file from its download
> location into the library? Or do I have to use gnomevfs.xfer_uri?

I think either would work, unless you needed to present authentication
information or cookies or something, in which case you'd probably need
to use gnomevfs.

> That's all I can think of at the moment. Thanks in advance for any help!

Hopefully I've given you some helpful information here.  Good luck!





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