static void playlist_metadata_foreach (const char *key, const char *value, gpointer data) { RBPodcastChannel *channel = (RBPodcastChannel *) data; if (strcmp (key, TOTEM_PL_PARSER_FIELD_TITLE) == 0) { channel->title = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_LANGUAGE) == 0) { channel->lang = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_DESCRIPTION) == 0) { channel->description = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_AUTHOR) == 0) { channel->author = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_CONTACT) == 0) { channel->contact = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_IMAGE_URI) == 0) { channel->img = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_PUB_DATE) == 0) { channel->pub_date = totem_pl_parser_parse_date (value, FALSE); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_COPYRIGHT) == 0) { channel->copyright = g_strdup (value); } }
static void process_results (RBPodcastSearchMiroGuide *search, JsonParser *parser) { JsonArray *results; guint i; results = json_node_get_array (json_parser_get_root (parser)); for (i = 0; i < json_array_get_length (results); i++) { JsonObject *feed; JsonArray *items; RBPodcastChannel *channel; int j; feed = json_array_get_object_element (results, i); channel = g_new0 (RBPodcastChannel, 1); channel->url = g_strdup (json_object_get_string_member (feed, "url")); channel->title = g_strdup (json_object_get_string_member (feed, "name")); channel->author = g_strdup (json_object_get_string_member (feed, "publisher")); /* hrm */ channel->img = g_strdup (json_object_get_string_member (feed, "thumbnail_url")); channel->is_opml = FALSE; rb_debug ("feed %d: url %s, name \"%s\"", i, channel->url, channel->title); items = json_object_get_array_member (feed, "item"); for (j = 0; j < json_array_get_length (items); j++) { JsonObject *episode = json_array_get_object_element (items, j); RBPodcastItem *item; item = g_new0 (RBPodcastItem, 1); item->title = g_strdup (json_object_get_string_member (episode, "name")); item->url = g_strdup (json_object_get_string_member (episode, "url")); item->description = g_strdup (json_object_get_string_member (episode, "description")); item->pub_date = totem_pl_parser_parse_date (json_object_get_string_member (episode, "date"), FALSE); item->filesize = json_object_get_int_member (episode, "size"); rb_debug ("item %d: title \"%s\", url %s", j, item->title, item->url); channel->posts = g_list_prepend (channel->posts, item); } channel->posts = g_list_reverse (channel->posts); rb_debug ("finished parsing items"); rb_podcast_search_result (RB_PODCAST_SEARCH (search), channel); rb_podcast_parse_channel_free (channel); } }
static void entry_metadata_foreach (const char *key, const char *value, gpointer data) { RBPodcastItem *item = (RBPodcastItem *) data; if (strcmp (key, TOTEM_PL_PARSER_FIELD_TITLE) == 0) { item->title = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_URI) == 0) { item->url = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_DESCRIPTION) == 0) { item->description = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_AUTHOR) == 0) { item->author = g_strdup (value); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_PUB_DATE) == 0) { item->pub_date = totem_pl_parser_parse_date (value, FALSE); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_DURATION) == 0) { item->duration = totem_pl_parser_parse_duration (value, FALSE); } else if (strcmp (key, TOTEM_PL_PARSER_FIELD_FILESIZE) == 0) { item->filesize = g_ascii_strtoull (value, NULL, 10); } }