#!/bin/bash # YT Download installer for Chrome on Mac. https://yt.shivammehta.dev # # curl -fsSL https://yt.shivammehta.dev/install | bash # # What it does (nothing here needs your password): # 1. installs yt-dlp, ffmpeg and deno with Homebrew, if they're missing # 2. downloads the extension from the site and checks its SHA-256 # 3. puts it in ~/Library/Application Support/YT Download # 4. registers the small helper Chrome uses to run yt-dlp # 5. opens chrome://extensions and copies the folder's location, ready for # Developer mode -> Load unpacked (the one step Chrome won't let a script do) # # Run it again any time to update. # Generated by package.sh from dist/get.sh.in: version 1.1.1. set -euo pipefail main() { local VERSION="1.1.1" local SHA256="c68a5ddde88daa114b0960ea212ac1f241aaf2132055e694f18d3d20ab431d6e" local BASE="${YTDL_BASE_URL:-https://yt.shivammehta.dev}" local DEST="${YTDL_DEST:-$HOME/Library/Application Support/YT Download}" local ZIP_URL="$BASE/downloads/yt-download-$VERSION.zip" local GUI="${YTDL_NO_GUI:-}" local B="" D="" R="" if [ -t 1 ]; then B=$'\033[1m'; D=$'\033[2m'; R=$'\033[0m'; fi say() { printf '%s\n' "$*"; } step() { printf '\n%s==> %s%s\n' "$B" "$*" "$R"; } die() { printf '\n%sError:%s %s\n' "$B" "$R" "$*" >&2; exit 1; } [ "$(uname -s)" = "Darwin" ] || die "YT Download is for macOS." if [ ! -d "/Applications/Google Chrome.app" ] && [ ! -d "$HOME/Applications/Google Chrome.app" ]; then say "${D}Google Chrome wasn't found in Applications. Install it from https://www.google.com/chrome/ first.${R}" fi step "Checking helpers" local BREW="" for c in /opt/homebrew/bin/brew /usr/local/bin/brew "$(command -v brew 2>/dev/null || true)"; do if [ -n "$c" ] && [ -x "$c" ]; then BREW="$c"; break; fi done if [ -z "$BREW" ]; then die "Homebrew is needed to install yt-dlp and ffmpeg. Install it from https://brew.sh (one command), then run this installer again." fi have() { local d for d in /opt/homebrew/bin /usr/local/bin; do [ -x "$d/$1" ] && return 0; done command -v "$1" >/dev/null 2>&1 } local missing=() p for p in yt-dlp ffmpeg deno; do have "$p" || missing+=("$p"); done if [ "${#missing[@]}" -gt 0 ]; then say "Installing ${missing[*]} with Homebrew (this can take a few minutes)…" "$BREW" install "${missing[@]}" "$tmp/install.log" 2>&1 || { cat "$tmp/install.log" >&2; die "Setting up the helper failed (log above)."; } say "Helper registered with Chrome." local EXT="$DEST/extension" if [ -n "$updating" ]; then step "Updated to $VERSION" say "In chrome://extensions, click the reload icon on YT Download, then refresh YouTube." return 0 fi if [ -z "$GUI" ]; then printf '%s' "$EXT" | pbcopy open -a "Google Chrome" "chrome://extensions/" 2>/dev/null || true fi step "Last step, in Chrome" say "The extension's folder location is copied. In Chrome's Extensions page (chrome://extensions):" say " 1. Turn on ${B}Developer mode${R} (top right)." say " 2. Click ${B}Load unpacked${R}, press ${B}⌘⇧G${R}, paste with ${B}⌘V${R}, press Return, then click ${B}Select${R}." say " 3. Open any YouTube video. The Download button sits next to Share." say "" say "${D}Folder: $EXT${R}" } main "$@"