R/get_gallery.r

Defines functions get_gallery

Documented in get_gallery

get_gallery <- 
function(section = 'hot',
         sort = 'viral',
         page = 0,
         window = 'day',
         showViral = TRUE,
         ...){
    stopifnot(section %in% c('hot', 'top', 'user'))
    if(!is.null(window))
       stopifnot(window %in% c('day', 'week', 'month', 'year', 'all'))
    stopifnot(sort %in% c('viral', 'time'))
    stopifnot(is.numeric(as.numeric(page)))
    stopifnot(is.logical(showViral))
    out <- imgurGET(paste0('gallery/', section, '/', sort,
                           ifelse(section == 'top', paste0('/', window), 
                                                    ''),
                           '/', page,
                           ifelse(section == 'user', paste0('?showViral=', showViral),
                                                     '')),
                    ...)
    out <- lapply(out, `class<-`, 'imgur_gallery_image')
    structure(out, class = 'imgur_gallery_album')
}

Try the imguR package in your browser

Any scripts or data that you put into this service are public.

imguR documentation built on May 2, 2019, 4:02 p.m.