#!/bin/zsh
use media/youtube
#####################################################################
MAIN() {
local URLS=($@)
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_USER_INPUT 'enter URL'))
[[ ${#URLS[@]} -eq 0 ]] && ABORT
local FILENAME=$(YT__GET_FILENAME $URLS)
[ ! $FILENAME ] && ERROR "unable to download '$URLS'"
SUCCESS "Found '$FILENAME'"
Yn "Proceed with download?" || return 1
YT__DOWNLOAD $URLS \
&& SUCCESS "downloaded to '$YT__OUTPUT_DIR/$FILENAME'" \
|| { ERROR "failed to download '$FILENAME'"; return 2; }
}