Пример #1
0
static gpointer
parse_thread (ParseThreadData *data)
{
	if (rb_podcast_parse_load_feed (data->channel, data->url, FALSE, &data->error) == FALSE) {
		/* fake up a channel with just the url as the title, allowing the user
		 * to subscribe to the podcast anyway.
		 */
		data->channel->url = g_strdup (data->url);
		data->channel->title = g_strdup (data->url);
	}

	g_idle_add ((GSourceFunc) parse_finished, data);
	return NULL;
}
int main (int argc, char **argv)
{
	RBPodcastChannel *data;
	GList *l;
	GDate date = {0,};
	char datebuf[1024];
	GError *error = NULL;

	g_type_init ();
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

	if (argv[2] != NULL && strcmp (argv[2], "--debug") == 0) {
		debug = TRUE;
	}

	data = g_new0 (RBPodcastChannel, 1);
	if (rb_podcast_parse_load_feed (data, argv[1], FALSE, &error) == FALSE) {
		g_warning ("Couldn't parse %s: %s", argv[1], error->message);
		g_clear_error (&error);
		return 1;
	}

	g_date_set_time_t (&date, data->pub_date);
	g_date_strftime (datebuf, 1024, "%F %T", &date);

	g_print ("Podcast title: %s\n", data->title);
	g_print ("Description: %s\n", data->description);
	g_print ("Author: %s\n", data->author);
	g_print ("Date: %s\n", datebuf);
	g_print ("\n");

	for (l = data->posts; l != NULL; l = l->next) {
		RBPodcastItem *item = l->data;

		g_date_set_time_t (&date, item->pub_date);
		g_date_strftime (datebuf, 1024, "%F %T", &date);

		g_print ("\tItem title: %s\n", item->title);
		g_print ("\tURL: %s\n", item->url);
		g_print ("\tAuthor: %s\n", item->author);
		g_print ("\tDate: %s\n", datebuf);
		g_print ("\tDescription: %s\n", item->description);
		g_print ("\n");
	}

	return 0;
}