
Get video metadata and video files from URLs
Source:R/api_hidden.r, R/shorthands.r
tt_videos_hidden.RdUsage
tt_videos_hidden(
video_urls,
save_video = TRUE,
overwrite = FALSE,
dir = ".",
cache_dir = NULL,
sleep_pool = 1:10,
max_tries = 5L,
cookiefile = NULL,
verbose = interactive(),
slideshows = "ask",
...
)
tt_videos(...)Arguments
- video_urls
vector of URLs or IDs to TikTok videos.
- save_video
logical. Should the videos be downloaded.
- overwrite
logical. If save_video=TRUE and the file already exists, should it be overwritten?
- dir
directory to save videos files to.
- cache_dir
if set to a path, one RDS file with metadata will be written to disk for each video. This is useful if you have many videos and want to pick up where you left if something goes wrong.
- sleep_pool
a vector of numbers from which a waiting period is randomly drawn.
- max_tries
how often to retry if a request fails.
path to your cookiefile. Usually not needed after running auth_hidden once. See
vignette("unofficial-api", package = "traktok")for more information on authentication.- verbose
should the function print status updates to the screen?
- slideshows
what to do when a URL turns out to be a slideshow (photo post). TikTok does not include data for these in the page source, so they have to be opened in a (headless) browser, which is slower and needs the
chromotepackage."ask"(the default) asks whether to do that once all other posts are collected (treated asFALSEin non-interactive sessions),TRUEdoes it without asking, andFALSEleaves the rows empty. See tt_slideshow_hidden.- ...
handed to
tt_videos_hidden(for tt_videos) and (further) to tt_request_hidden.
Details
The function will wait between scraping two videos to make it less
obvious that a scraper is accessing the site. The period is drawn randomly
from the sleep_pool and multiplied by a random fraction.
Note that the video file has to be requested in the same session as the metadata. So while the URL to the video file is included in the metadata, this link will not work in most cases.
Slideshows (photo posts) are collected differently, see
slideshows and tt_slideshow_hidden. Their images are
downloaded instead of a video file if save_video = TRUE.