Skip to content

Commit

Permalink
skip wait when vid cached
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Feb 16, 2024
1 parent f3f3834 commit b7eafb9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/api_hidden.r
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ tt_videos_hidden <- function(video_urls,
}
}

if (i != n_urls) wait(sleep_pool, verbose)
if (i != n_urls && !isTRUE(the$skipped)) {
wait(sleep_pool, verbose)
the$skipped <- FALSE
}

return(video_dat)
}))
Expand All @@ -132,10 +135,12 @@ get_video <- function(url,

if (overwrite || !file.exists(json_fn)) {
tt_json <- tt_request_hidden(url, max_tries = max_tries)
if (!is.null(cache_dir)) writeLines(tt_json, json_fn, useBytes = TRUE)
} else {
tt_json <- readChar(json_fn, nchars = file.size(json_fn), useBytes = TRUE)
attr(tt_json,"url_full") <- url
}

if (!is.null(cache_dir)) writeLines(tt_json, json_fn, useBytes = TRUE)

parse_video(tt_json, video_id)
}

Expand Down Expand Up @@ -172,6 +177,7 @@ save_video <- function(video_url,
}
} else if (file.exists(video_fn)) {
f <- video_fn
the$skipped <- TRUE
}

} else {
Expand Down

0 comments on commit b7eafb9

Please sign in to comment.