1

我曾经通过调用“rhythmbox [播客的网址]”来订阅新的播客,但由于这个错误,这不再有效。它只是打开 Rhythmbox,而不是打开和订阅。(尽管如果您碰巧在播客部分单击“添加”,它会预先填充它)

GTK3 应用程序之间是否有一些新的通信方式,或者应用程序没有办法简单地告诉 Rhythmbox 订阅某个播客?

更新:在这里查看答案,我发现以下内容在 iPython 中有很多 tab 键:

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)

这似乎是正确的 API,但论据是什么?它会在 GTK3 之前的系统中工作吗?

更新在这里通过Python api,我想我几乎拥有它:

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

看来 add_parsed_feed 上的文档不正确,需要 2 个参数,而不是 1 个。我知道内部类的函数是用 定义的def thing(self, firstarg),这是否会导致 Python 绑定到 Rhythmbox 出现问题?为什么我不能将解析后的播客添加到 Rhythmbox 中?

4

1 回答 1

1

您需要PodcastManager在调用之前实例化对象add_parsed_feed,以便 self将其作为第一个参数隐式提供:

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

或者

RB.PodcastManager().add_parsed_feed(mypod)

当您以这种方式调用它时,该add_parsed_feed方法将绑定到RB.PodcastManager您创建的实例。当您调用绑定方法时,它绑定到的实例 ( manager,在这种情况下) 将自动作为第一个参数提供(最终将selfadd_parsed_feed..

另一方面,当您调用 时RB.PodcastManager.add_parsed_feed,该add_parsed_feed方法未绑定到 的任何实例RB.PodcastManager,因此 Python 无法自动提供该实例作为第一个参数。这就是为什么您会收到有关仅提供一个参数的错误的原因。

编辑:

请注意,使用此 API 似乎无法正常工作;即使我从嵌入到 Rhythmbox 的 Python 控制台中使用它,它似乎总是对我来说是段错误。如果您不介意编辑 Rhythmbox 源代码并自己构建它,那么获得您想要的行为实际上非常容易——这只是一行更改。在函数中shell/rb-shell.crb_shell_load_uri更改此行:

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

对此:

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

然后重建。现在,当您在启动节奏盒时包含播客 URI 时,它将订阅提要并开始播放。

这是补丁形式的变化:

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;
        }
于 2014-09-05T02:43:45.753 回答