Subscribe-to-podcast fails - wants 2 arguments, not 1?

198 views Asked by At

I used to subscribe new podcasts by calling "rhythmbox [url of podcast]", but that is no longer working due to this bug. It just opens Rhythmbox instead of opening and subscribing. (although it does pre-fill it if you happen to click "add" in the podcast section)

Is there some new way GTK3 apps are supposed to communicate with each other, or is there just no way for an app to simply tell Rhythmbox to subscribe a certain podcast?

Update: Looking at an answer here I found the following with a lot of tab key in iPython:

from gi.repository import RB
 ....
In [2]: RB.PodcastManager.insert_feed_url
Out[2]: gi.FunctionInfo(insert_feed_url)

In [3]: RB.PodcastManager.insert_feed_url('http://feeds.feedburner.com/NodeUp')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-b6415d6bfb17> in <module>()
----> 1 RB.PodcastManager.insert_feed_url('http://feeds.feedburner.com/NodeUp')

TypeError: insert_feed_url() takes exactly 2 arguments (1 given)

This seems like the right API, but what are the arguments? Will it work in systems pre-GTK3?

Update Going through the Python api here, I think I almost have it:

from gi.repository import RB
mypod = RB.PodcastChannel() #Creates blank podcast object
RB.podcast_parse_load_feed(mypod, 'http://wpdevtable.com/feed/podcast/', False)
#loads mypod.url, mypod.description etc.

RB.PodcastManager.add_parsed_feed(mypod); #fails

It appears the documentation on add_parsed_feed is incorrect, and wants 2 arguments, not 1. I know internally class' functions are defined with def thing(self, firstarg), is this causing a problem here with Python bindings to Rhythmbox somehow? Why can I not add the parsed podcast into Rhythmbox?

1

There are 1 answers

14
dano On

You need to instantiate the PodcastManager object before you call add_parsed_feed, so that self will be implicitly provided as the first argument:

manager = RB.PodcastManager()
manager.add_parsed_feed(mypod)

or

RB.PodcastManager().add_parsed_feed(mypod)

When you call it this way, the add_parsed_feed method is bound to the RB.PodcastManager instance you created. When you call a bound method, the instance it's bound to (manager, in this case) will automatically be provided as the first argument (which will end up being self inside of add_parsed_feed)..

On the other hand, when you call RB.PodcastManager.add_parsed_feed, the add_parsed_feed method isn't bound to any instance of RB.PodcastManager, so Python can't automatically provide that instance as the first argument. That's why you get the error about only one argument being provided.

Edit:

Note that it doesn't look like using this API works properly; it always seems to segfault for me, even if I use it from the Python console embedded into Rhythmbox. Getting the behavior you want is actually really easy if you don't mind editing the Rhythmbox source code and building it yourself - it's just a one line change. In shell/rb-shell.c, in the rb_shell_load_uri function, change this line:

rb_podcast_source_add_feed (shell->priv->podcast_source, uri);

To this:

rb_podcast_manager_subscribe_feed (shell->priv->podcast_manager, uri, TRUE);

Then rebuild. Now, when you include a podcast URI when you start rhythmbox, it will subscribe to the feed and start playing.

Here's the change in patch form:

diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 77526d9..e426396 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -2995,7 +2995,7 @@ rb_shell_load_uri (RBShell *shell,
        /* If the URI points to a Podcast, pass it on to the Podcast source */
        if (rb_uri_could_be_podcast (uri, NULL)) {
                rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->podcast_source));
-               rb_podcast_source_add_feed (shell->priv->podcast_source, uri);
+               rb_podcast_manager_subscribe_feed (shell->priv->podcast_manager, uri, TRUE);
                return TRUE;
        }