diff --git a/R/atom_parse.R b/R/atom_parse.R index a96cf37..4ef215c 100644 --- a/R/atom_parse.R +++ b/R/atom_parse.R @@ -7,7 +7,7 @@ atom_parse <- function(response, list, clean_tags, parse_dates) { # get default namespace ns_entry <- xml_ns(res) %>% attributes() %>% .[[1]] %>% .[[1]] - # metadata: id, title, updated necessary, + # metadata: id, title, updated necessary metadata <- tibble( feed_title = xml_find_first(res, glue("{ns_entry}:title")) %>% xml_text(), feed_url = xml_find_first(res, glue("{ns_entry}:id")) %>% xml_text(), @@ -38,10 +38,7 @@ atom_parse <- function(response, list, clean_tags, parse_dates) { meta <- bind_cols(metadata, meta_optional) # entries # necessary: id, title, updated - res_entry <- xml_find_all(res, glue("{ns_entry}:entry")) - e_link <- xml_find_first(res_entry, glue("{ns_entry}:link")) %>% - xml_attr("href") # optional entries <- tibble( @@ -51,7 +48,8 @@ atom_parse <- function(response, list, clean_tags, parse_dates) { entry_author = safe_run(res_entry, "all", glue("{ns_entry}:author")), entry_enclosure = safe_run(res_entry, "all", glue("{ns_entry}:enclosure")), entry_content = safe_run(res_entry, "all", glue("{ns_entry}:content")), - entry_link = ifelse(!is.null(e_link), e_link, def), + # https://github.com/RobertMyles/tidyRSS/issues/70 + entry_link = xml_attr(xml_find_first(res_entry, glue("{ns_entry}:link")),"href"), entry_summary = safe_run(res_entry, "all", glue("{ns_entry}:summary")), entry_category = list(NA), entry_published = safe_run(res_entry, "all", glue("{ns_entry}:published")), diff --git a/R/json_parse.R b/R/json_parse.R index 644ce4d..78de3b1 100644 --- a/R/json_parse.R +++ b/R/json_parse.R @@ -14,8 +14,7 @@ json_parse <- function(response, list, clean_tags, parse_dates) { language = return_exists(res$language), expired = return_exists(res$expired), icon = return_exists(res$icon), - favicon = return_exists(res$favicon), - expired = return_exists(res$expired) + favicon = return_exists(res$favicon) ) entries <- tibble( diff --git a/R/rss_parse.R b/R/rss_parse.R index 22503c9..8628999 100644 --- a/R/rss_parse.R +++ b/R/rss_parse.R @@ -13,7 +13,7 @@ rss_parse <- function(response, list, clean_tags, parse_dates) { ) # optional metadata: language, copyright, managingEditor, webMaster, pubDate, # lastBuildDate; category, generator, docs, cloud, link, managingEditor, - # podcast:guid, podcast:license, podcast:locked, podcast:funding, + # podcast:guid, podcast:license, podcast:locked, podcast:funding, # podcast:location, podcast:trailer, ttl, image, textInput, # skipHours, skipDays meta_optional <- tibble( @@ -29,7 +29,6 @@ rss_parse <- function(response, list, clean_tags, parse_dates) { )), feed_generator = safe_run(channel, "first", "//*[name()='generator']"), feed_docs = safe_run(channel, "first", "//*[name()='docs']"), - feed_link = safe_run(channel, "first", "//*[name()='link']"), feed_managingEditor = safe_run(channel, "first", "//*[name()='managingEditor']"), feed_webMaster = safe_run(channel, "first", "//*[name()='webMaster']"), feed_guid = safe_run(channel, "first", "//*[name()='podcast:guid']"), @@ -50,11 +49,10 @@ rss_parse <- function(response, list, clean_tags, parse_dates) { item_title = map(res_entry, "title", .default = def) %>% unlist(), item_link = map(res_entry, "link", .default = def) %>% unlist(), item_description = map(res_entry, "description", .default = def) %>% - unlist() %>% discard(safe_check_comment), + replace_null() %>% discard(safe_check_comment) %>% unlist(), item_pub_date = map(res_entry, "pubDate", .default = def) %>% unlist(), item_guid = map(res_entry, "guid", .default = def) %>% unlist(), item_author = map(res_entry, "author", .default = def), - item_enclosure = map(res_entry, "enclosure", .default = def), item_season = map(res_entry, "podcast:season", .default = def), item_episode = map(res_entry, "podcast:episode", .default = def), item_enclosure = map(res_entry, "enclosure", .default = def), diff --git a/R/utils.R b/R/utils.R index 756fdb5..aea5a2d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -121,3 +121,10 @@ safe_check_comment <- function(x) { } x == "[ comment ]" } + +# From https://github.com/RobertMyles/tidyRSS/issues/69 + +replace_null <- function(x){ + x <- map(x, ~ replace(.x, is.null(.x), NA_character_)) + map(x, ~ if(is.list(.x)) replace_null(.x) else .x) +}