-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.R
60 lines (49 loc) · 1.54 KB
/
run.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Setup -----------------------------------------------------------
options(tidyverse.quiet = TRUE)
library(progressr)
library(tidyverse)
library(dbplyr, warn.conflicts = FALSE)
library(DBI)
library(here)
progressr::handlers(progressr::handler_progress(
format = ":spin step :current/:total (:message) [:bar] :percent in :elapsed ETA: :eta",
complete = "+",
clear = FALSE
))
list.files(here("R"), pattern = "\\.R$", full.names = TRUE) |>
walk(source, echo = FALSE)
# Data ------------------------------------------------------------
videos <- list.files(
path = "E:/",
full.names = TRUE,
recursive = TRUE,
pattern = "\\.mp4$",
ignore.case = TRUE,
no.. = TRUE
) |>
stringr::str_subset("^.*/\\..*$", negate = TRUE)
# Run -------------------------------------------------------------
with_progress({
freshstart <- FALSE
db_name <- "E:/transcripts.sqlite"
is_db_there <- fs::file_exists(db_name) &&
fs::file_info(db_name)[["size"]]
con <- withr::local_db_connection(
DBI::dbConnect(RSQLite::SQLite(), db_name)
)
if (!is_db_there || freshstart) {
dbExecute(con, "DROP TABLE IF EXISTS videos", immediate = TRUE)
dbExecute(con, "CREATE TABLE videos
(
id INTEGER PRIMARY KEY, -- Autoincrement
timestamp TIMESTAMP,
folder TEXT,
video INTEGER,
audio INTEGER,
text INTEGER,
done LOGICAL
)
", immediate = TRUE)
}
res <- run(videos, con = con, table = "videos")
}, delay_terminal = FALSE)