Created
January 4, 2017 14:25
-
-
Save jsta/34ecc7bbe49f615e0d677724fa155d60 to your computer and use it in GitHub Desktop.
R script to interact with the handbrakeCLI program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# need to apt-get: | |
# * libdvdcsss2 | |
# * handbrake-cli | |
handbrake_scan <- function(source){ | |
cli <- paste0("HandBrakeCLI -i ", source, " --scan") | |
system(cli) | |
} | |
handbrake_scan("/media/user/disc") | |
handbrake_get <- function(source, | |
chapter_start, chapter_end, title, season, dest_folder){ | |
chapter_seq <- chapter_start:chapter_end | |
dbl_pad <- function(x){ | |
if(nchar(x) == 1){ | |
paste0("0", x) | |
}else{ | |
x | |
} | |
} | |
get_chapter <- function(chapter){ | |
outpath <- paste0("'", dest_folder, title, " - ", "s", | |
dbl_pad(season), "e", dbl_pad(chapter), ".m4v", "'") | |
cli <- paste0("HandBrakeCLI -i ", source, " -t ", chapter, " -o ", outpath) | |
cli | |
} | |
lapply(chapter_seq, function(x) system(get_chapter(x))) | |
} | |
handbrake_get(source = "/media/user/disc", | |
chapter_start = 1, | |
chapter_end = 10, | |
title = "Disc Title", | |
season = 1, | |
dest_folder = "/videos-folder/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment