|
73 | 73 | #' ### you can see available licenses with cr_licenses() function
|
74 | 74 | #' out <-
|
75 | 75 | #' cr_works(filter = list(has_full_text = TRUE,
|
76 |
| -#' license_url="http://creativecommons.org/licenses/by/3.0/")) |
77 |
| -#' (links <- cr_ft_links(out$data$DOI[10], "all")) |
78 |
| -#' cr_ft_text(links, 'xml') |
| 76 | +#' license_url="http://creativecommons.org/licenses/by/3.0/"), |
| 77 | +#' limit = 100) |
| 78 | +#' (links <- cr_ft_links(out$data$DOI[40], "all")) |
| 79 | +#' # cr_ft_text(links, 'xml') |
79 | 80 | #'
|
80 | 81 | #' ## You can use cr_ft_xml, cr_ft_plain, and cr_ft_pdf to go directly to
|
81 | 82 | #' ## that format
|
82 | 83 | #' licenseurl <- "http://creativecommons.org/licenses/by/3.0/"
|
83 | 84 | #' out <- cr_works(
|
84 |
| -#' filter = list(has_full_text = TRUE, license_url = licenseurl)) |
85 |
| -#' (links <- cr_ft_links(out$data$DOI[10], "all")) |
| 85 | +#' filter = list(has_full_text = TRUE, license_url = licenseurl), |
| 86 | +#' limit = 100) |
| 87 | +#' (links <- cr_ft_links(out$data$DOI[50], "all")) |
86 | 88 | #' cr_ft_xml(links)
|
87 |
| -#' cr_ft_pdf(links) |
| 89 | +#' #cr_ft_pdf(links) |
88 | 90 | #'
|
89 |
| -#' # Caching, for PDFs |
90 |
| -#' out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE) |
91 |
| -#' (links <- cr_ft_links(out$data$DOI[10], "all")) |
92 |
| -#' cr_ft_text(links, type = "pdf", cache=FALSE) |
93 |
| -#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) ) |
94 |
| -#' # second time should be faster |
95 |
| -#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) ) |
96 |
| -#' system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) ) |
97 |
| -#' identical(cacheyes, cacheno) |
| 91 | +#' ### Caching, for PDFs |
| 92 | +#' # out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE) |
| 93 | +#' # (links <- cr_ft_links(out$data$DOI[10], "all")) |
| 94 | +#' # cr_ft_text(links, type = "pdf", cache=FALSE) |
| 95 | +#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) ) |
| 96 | +#' ### second time should be faster |
| 97 | +#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) ) |
| 98 | +#' # system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) ) |
| 99 | +#' # identical(cacheyes, cacheno) |
98 | 100 | #'
|
99 | 101 | #' ## elsevier
|
100 | 102 | #' ## requires extra authentication
|
@@ -178,20 +180,29 @@ get_url <- function(a, b){
|
178 | 180 | #' @rdname cr_ft_text
|
179 | 181 | cr_ft_plain<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
|
180 | 182 | verbose=TRUE, ...) {
|
| 183 | +if (is.null(url$plain[[1]])) { |
| 184 | + stop("no plain text link found", call.=FALSE) |
| 185 | + } |
181 | 186 | getTEXT(url$plain[[1]], "plain", cr_auth(url, 'plain'), ...)
|
182 | 187 | }
|
183 | 188 |
|
184 | 189 | #' @export
|
185 | 190 | #' @rdname cr_ft_text
|
186 | 191 | cr_ft_xml<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
|
187 | 192 | verbose=TRUE, ...) {
|
| 193 | +if (is.null(url$xml[[1]])) { |
| 194 | + stop("no xml link found", call.=FALSE) |
| 195 | + } |
188 | 196 | getTEXT(url$xml[[1]], "xml", cr_auth(url, 'xml'), ...)
|
189 | 197 | }
|
190 | 198 |
|
191 | 199 | #' @export
|
192 | 200 | #' @rdname cr_ft_text
|
193 | 201 | cr_ft_pdf<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
|
194 | 202 | cache=FALSE, verbose=TRUE, ...) {
|
| 203 | +if (is.null(url$pdf[[1]])) { |
| 204 | + stop("no pdf link found", call.=FALSE) |
| 205 | + } |
195 | 206 | getPDF(url$pdf[[1]], path, cr_auth(url, 'pdf'), overwrite, "pdf",
|
196 | 207 | read, verbose, cache, ...)
|
197 | 208 | }
|
|
0 commit comments