Created
June 8, 2015 14:51
-
-
Save ssh0/284125fc90a1e47fd348 to your computer and use it in GitHub Desktop.
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
#-------- youtube-dl completion {{{ | |
# put this script in your .zshrc | |
# generated by: | |
# https://github.com/rg3/youtube-dl/blob/master/devscripts/zsh-completion.in | |
# https://github.com/rg3/youtube-dl/blob/master/devscripts/zsh-completion.py | |
# and modified manually | |
__youtube_dl() { | |
local curcontext="$curcontext" fileopts diropts cur prev | |
typeset -A opt_args | |
fileopts="--download-archive|-a|--batch-file|--load-info|--cookies|--ffmpeg-location" | |
diropts="--cache-dir" | |
local ddir="/media/shotaro/STOCK/Videos" | |
cur=$words[CURRENT] | |
case $cur in | |
:) | |
_arguments '*: :(::ytfavorites ::ytrecommended ::ytsubscriptions ::ytwatchlater ::ythistory)' | |
;; | |
*) | |
prev=$words[CURRENT-1] | |
if [[ ${prev} =~ ${fileopts} ]]; then | |
_path_files | |
elif [[ ${prev} =~ ${diropts} ]]; then | |
_path_files -/ | |
elif [[ ${prev} == "--recode-video" ]]; then | |
_arguments '*: :(mp4 flv ogg webm mkv)' | |
elif [[ ${prev} == "--audio-format" ]]; then | |
_arguments '*: :(best aac vorbis mp3 m4a opus wav)' | |
elif [[ ${prev} == "--convert-subtitle" ]]; then | |
_arguments '*: :(srt ass vtt)' | |
elif [[ ${prev} =~ "-o|--output" ]]; then | |
_arguments "*: :(\ | |
'${ddir}/%(title)s.%(ext)s' \ | |
'${ddir}/%(autonumber)s - %(title)s.%(ext)s' \ | |
'${ddir}/%(extractor)s/%(title)s.%(ext)s' \ | |
'-' \ | |
)" | |
elif [[ ${prev} == "--proxy" ]]; then | |
_arguments "*: :( `echo ${http_proxy}` )" | |
else | |
_arguments -S\ | |
'-h[Print help]: :' \ | |
'-U[Update the program (run with root)]: :' \ | |
'-i[Continue on download errors]' \ | |
'(-6)-4[Make all connections via IPv4]' \ | |
'(-4)-6[Make all connections via IPv6]' \ | |
'-r[Maximum download rate in bytes per second (e.g. 50K or 4.2M)]' \ | |
'-R[Number of retries (default is 10), or "infinite"]' \ | |
'-a[File containg URLs to download ('-' for stdin)]' \ | |
'-o[Output filename template. (See manpage)]' \ | |
'-q[Activate quiet mode]' \ | |
'-s[Do not download the video and do not write anything to disk]' \ | |
'-g[Simulate, quiet but print URL]' \ | |
'-e[Simulate, quiet but print title]' \ | |
'-j[Simulate, quiet but print JSON information]' \ | |
'-J[Simulate, quiet but print JSON information for each command-line argument]' \ | |
'-f[Video format code, see the "FORMAT SELECTION" for all the info]' \ | |
'-F[List all available formats]' \ | |
'-u[Login with this account ID]' \ | |
'-p[Account pass word. If this option is left out, youtube-dl will ask interactively]' \ | |
'-2[Two-factor auth code]' \ | |
'-n[Use .netrc authentication data]' \ | |
'-x[Convert video files to audio-only files]' \ | |
'-k[Keep the video file on disk after the post-processing; the video is erased by default]' \ | |
'*: :(--help --version --update --ignore-errors --abort-on-error --dump-user-agent --list-extractors --extractor-descriptions --default-search --ignore-config --flat-playlist --no-color --proxy --socket-timeout --source-address --force-ipv3 --force-ipv6 --cn-verification-proxy --playlist-start --playlist-end --playlist-items --match-title --reject-title --max-downloads --min-filesize --max-filesize --date --datebefore --dateafter --min-views --max-views --match-filter --no-playlist --yes-playlist --age-limit --download-archive --include-ads --rate-limit --retries --buffer-size --no-resize-buffer --test --playlist-reverse --xattr-set-filesize --hls-prefer-native --external-downloader --external-downloader-args --batch-file --id --output --autonumber-size --restrict-filenames --no-overwrites --continue --no-continue --no-part --no-mtime --write-description --write-info-json --write-annotations --load-info --cookies --cache-dir --no-cache-dir --rm-cache-dir --write-thumbnail --write-all-thumbnails --list-thumbnails --quiet --no-warnings --simulate --skip-download --get-url --get-title --get-id --get-thumbnail --get-description --get-duration --get-filename --get-format --dump-json --dump-single-json --print-json --newline --no-progress --console-title --verbose --dump-pages --write-pages --youtube-print-sig-code --print-traffic --call-home --no-call-home --no-check-certificate --prefer-insecure --user-agent --referer --add-header --bidi-workaround --sleep-interval --format --all-formats --prefer-free-formats --list-formats --youtube-include-dash-manifest --youtube-skip-dash-manifest --merge-output-format --write-sub --write-auto-sub --all-subs --list-subs --sub-format --sub-lang --username --password --twofactor --netrc --video-password --extract-audio --audio-format --audio-quality --recode-video --keep-video --no-post-overwrites --embed-subs --embed-thumbnail --add-metadata --metadata-from-title --xattrs --fixup --prefer-avconv --prefer-ffmpeg --ffmpeg-location --exec --convert-subtitles)' | |
fi | |
;; | |
esac | |
} | |
compdef __youtube_dl youtube-dl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment