1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* The Rhythmbox authors hereby grant permission for non-GPL compatible
9
* GStreamer plugins to be used and distributed together with GStreamer
10
* and Rhythmbox. This permission is above and beyond the permissions granted
11
* by the GPL license by which Rhythmbox is covered. If you modify this code
12
* you may extend this exception to your version of the code, but you are not
13
* obligated to do so. If you do not wish to do so, delete this exception
14
* statement from your version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
32
#include <glib-object.h>
33
#include <glib/gi18n.h>
35
#include "rb-podcast-search.h"
39
static gboolean debug = FALSE;
42
void rb_debug_realf (const char *func,
46
const char *format, ...) G_GNUC_PRINTF (5, 6);
48
/* For the benefit of the podcast parsing code */
50
rb_debug_realf (const char *func,
54
const char *format, ...)
62
va_start (args, format);
63
g_vsnprintf (buffer, 1024, format, args);
66
g_printerr (newline ? "%s:%d [%s] %s\n" : "%s:%d [%s] %s",
67
file, line, func, buffer);
71
result_cb (RBPodcastSearch *search, RBPodcastChannel *data)
76
g_date_set_time_t (&date, data->pub_date);
77
g_date_strftime (datebuf, 1024, "%F %T", &date);
79
g_print ("Result from %s\n", G_OBJECT_TYPE_NAME (search));
81
g_print ("Podcast title: %s\n", data->title);
82
g_print ("Description: %s\n", data->description);
83
g_print ("Author: %s\n", data->author);
84
g_print ("Date: %s\n", datebuf);
86
if (data->num_posts > 0) {
87
g_print ("Number of episodes: %d\n", data->num_posts);
91
g_print ("Number of episodes: %d\n", g_list_length (data->posts));
93
for (l = data->posts; l != NULL; l = l->next) {
94
RBPodcastItem *item = l->data;
96
g_date_set_time_t (&date, item->pub_date);
97
g_date_strftime (datebuf, 1024, "%F %T", &date);
99
g_print ("\tItem title: %s\n", item->title);
100
g_print ("\tURL: %s\n", item->url);
101
g_print ("\tAuthor: %s\n", item->author);
102
g_print ("\tDate: %s\n", datebuf);
103
g_print ("\tDescription: %s\n", item->description);
110
finished_cb (RBPodcastSearch *search, GMainLoop *loop)
112
g_print ("Search %s finished\n", G_OBJECT_TYPE_NAME (search));
115
g_main_loop_quit (loop);
119
int main (int argc, char **argv)
122
RBPodcastSearch *itunes;
123
RBPodcastSearch *miroguide;
127
setlocale (LC_ALL, "");
128
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
129
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
132
if (argv[2] != NULL && strcmp (argv[2], "--debug") == 0) {
136
loop = g_main_loop_new (NULL, FALSE);
138
itunes = RB_PODCAST_SEARCH (g_object_new (rb_podcast_search_itunes_get_type (), NULL));
139
miroguide = RB_PODCAST_SEARCH (g_object_new (rb_podcast_search_miroguide_get_type (), NULL));
141
g_signal_connect (itunes, "result", G_CALLBACK (result_cb), NULL);
142
g_signal_connect (miroguide, "result", G_CALLBACK (result_cb), NULL);
143
g_signal_connect (itunes, "finished", G_CALLBACK (finished_cb), loop);
144
g_signal_connect (miroguide, "finished", G_CALLBACK (finished_cb), loop);
146
rb_podcast_search_start (itunes, text, 10);
147
rb_podcast_search_start (miroguide, text, 10);
149
g_main_loop_run (loop);