yage
89e899d49d
===================================================================== --- New Scripts -------------------------- zsh ) database backup/restore - db/postgres/pg_dump - db/postgres/pg_restore - aws/rds/create-backup - aws/rds/load-backup redis-cached curl commands - redis/curl youtube download - youtube/download - youtube/get-audio-clip --- Changes ------------------------------ - 'scwrypts' executable now reloads upon execution to prevent staleness - added various options to improve api/cli; see 'scwrypts --help' for more --- Bug Fixes ---------------------------- - fixed an issue with .config settings' visibility to non-zsh scripts - fixed an issue with command arguments globbing too early
46 lines
846 B
Bash
46 lines
846 B
Bash
_DEPENDENCIES+=(
|
|
youtube-dl
|
|
ffmpeg
|
|
)
|
|
_REQUIRED_ENV+=()
|
|
source ${0:a:h}/../common.zsh
|
|
#####################################################################
|
|
|
|
YT__GLOBAL_ARGS=(
|
|
--no-call-home
|
|
--restrict-filenames
|
|
)
|
|
|
|
YT__OUTPUT_DIR="$SCWRYPTS_DATA_PATH/youtube"
|
|
|
|
YT__GET_INFO() {
|
|
youtube-dl --dump-json ${YT__GLOBAL_ARGS[@]} $@
|
|
}
|
|
|
|
YT__GET_FILENAME() {
|
|
YT__GET_INFO $@ \
|
|
| jq -r '._filename' \
|
|
| sed 's/\.[^.]*$/\.mp4/' \
|
|
;
|
|
}
|
|
|
|
YT__DOWNLOAD() {
|
|
local OUTPUT_DIR="$SCWRYPTS_DATA_PATH/youtube"
|
|
[ ! -d $YT__OUTPUT_DIR ] && mkdir -p $YT__OUTPUT_DIR
|
|
cd "$YT__OUTPUT_DIR"
|
|
youtube-dl ${YT__GLOBAL_ARGS[@]} $@ \
|
|
--format 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \
|
|
;
|
|
}
|
|
|
|
GET_VIDEO_LENGTH() {
|
|
local FILENAME="$1"
|
|
|
|
ffprobe \
|
|
-v quiet \
|
|
-show_entries format=duration \
|
|
-of default=noprint_wrappers=1:nokey=1 \
|
|
-i $FILENAME \
|
|
;
|
|
}
|