Skip to content

Commit

Permalink
#31 add download_zenodo wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Aug 7, 2020
1 parent b9f795e commit dd2ba14
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(ZenodoManager)
export(ZenodoRecord)
export(ZenodoRequest)
export(download_zenodo)
export(zen4RLogger)
import(httr)
import(jsonlite)
Expand Down
30 changes: 30 additions & 0 deletions R/zen4R_downloader.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' @name download_zenodo
#' @aliases download_zenodo
#' @title download_zenodo
#' @description \code{download_zenodo} allows to execute a workflow
#'
#' @usage download_zenodo("10.5281/zenodo.2547036")
#'
#' @param doi a Zenodo DOI or concept DOI
#' @param path the target directory where to download files
#' @param logger a logger to print messages. The logger can be either NULL,
#' "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
#' @param ... any other arguments for parallel downloading (more information at
#'\link{ZenodoManager}, \code{downloadFiles()} documentation)
#'
#' @export
#'
download_zenodo = function(doi, path = ".", logger = NULL, ...){

zenodo <- ZenodoManager$new(logger = logger)
rec <- zenodo$getRecordByDOI(doi)
if(is.null(rec)){
#try to get it as concept DOI
rec <- zenodo$getRecordByConceptDOI(doi)
if(is.null(rec)){
stop("The DOI specified doesn't match any existing Zenodo DOI or concept DOI")
}
}
#download
rec$downloadFiles(path = path, ...)
}
22 changes: 22 additions & 0 deletions man/download_zenodo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd2ba14

Please sign in to comment.