Re: [Rhythmbox-devel] RB Mp3Tunes plugin





On 6/19/07, James Doc Livingston <doclivingston gmail com> wrote:
On Sun, 2007-06-17 at 20:20 +0200, Federico Benedetto wrote:
> i'm writing a plugin to integrate Mp3Tunes in Rhythmbox
> ( http://bugzilla.gnome.org/show_bug.cgi?id=425140 ). I'm inspiring
> myself to the "magnatune plugin", but i'm encountering many problems:
>
> 1) Tracks are loaded always when the plugin is activated: how can i
> manage to let them load only when cliking on the Mp3Tunes source? And
> how can i create an "update" button?

rb.Source has an "impl_activate" vfunc which you can override in python
by using "def do_impl_activate ...". This can get called multiple times,
so you'll want to do something similar to the Magnatune plugin, viz:

def do_impl_activate (self):
    if not self.activated:
        self.activated = True
        # do your stuff here

    rb.BrowserSource.do_impl_activate (self)

Ok, i'll try that!

> 2) While loading the tracks, RB freezes completely for some
> minutes...i've read that i must use asynchronous IO, but i don't know
> how..can someone explain me?

With normal (synchronous) IO you call a method asking for some data, and
it blocks until the data arrives - which causes RB to freeze. With
asynchronous IO, you ask for the data but tell it to notify you when the
data is available, so the method returns immediately and doesn't freeze
the application.


How you should perform IO depends a bit on what the data is; you can
either wait until all the data is ready and get it handed you as one big
chunk, stream the data so little chunks get handed to you as it arrived,
or copy the data to a local file and then read it.


Is the data you're reading some kind of track catalogue? If so, it's
probably a reasonable size and is worth caching locally so it doesn't
have to be retrieved every time. What the magnatune plugin does is check
whether the remote version is newer than the local copy (if it exists),
and if we either don't have a copy or we have an out-of-date one
download it. Once downloaded it just parses it normally. The
__update_catalogue() method of MagnatuneSource will probably help, but
feel free to ask if you have more questions.

Interesting...i think i'll use the "update"  method, because the track informations are stored in a large xml file

> 3) How can I integrate my plugin with last.fm? I would like to have
> the tracks played in the Mp3Tunes source scrobbled!

They should automatically be scrobbled if the following conditions are
true:

1) the entry type belongs to the "normal" category (entry_type.category
is rhythmdb.ENTRY_NORMAL), which they are by default, not something else
like a stream.

2) the artist and title properties are set

3) the DURATION property is at least 30 seconds


Ok,  now they are scrobbled: it was only a server problem!

> 4) What format is "PROP_DATE" using? I can't manage to give it the
> right year

It's a Julian date, if you just have a year use:

import datetime
date = datetime.date(year, 1, 1).toordinal()
 

> 5) How can i create a simple configuration dialog where the user can
> specify his login informations?

Plugins can implement a method called "create_configure_dialog", which
has to return a GtkDialog. If you implement this, RB will enable the
configure button in the plugins dialog, and show your dialog when
clicked.

The lyrics plugin in svn, Magnatune plugin and Jamendo plugin all
implement this.



I'll write these up onto the wiki page[0] too, for future reference.


[0] http://live.gnome.org/RhythmboxPlugins/WritingGuide

Cheers,



Thank you for your answer!
I have one more question: when i try to copy a track to my library (copy or drag and drop), it gives me an error of this kind:
"impossible to open vfs file "file:///home/federico/Musica/The%20Kinks/The%20Village%20Green%20Preservation%20Society/26%20-%20Phenomenal%20Cat%20(stereo).com%2Fstorage%2Flockerget%2F1d16b876706186b1a52339389f4776da" in writing: URI not valid."

What is this problem?



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