Watch Netflix and YouTube offline on mac

Downie is great (as @kennonb mentions) the geeky answer I use would be:

  1. install youtube-dl on your mac via Nix or Homebrew
  1. copy urls and get them downloaded

This is how I do it:

  • I run a shortcut on my iOS device in the share-sheet to ask me what the title of the clip should be, transfers the url to a text file with the title as the name, that then ssh-es it over to folder on the mac
  • Hazel picks up the text file, lifts the url and name and feeds it into this script I modified from @tjluoma’s writeup here:

The script:

#!/usr/bin/env zsh -f

if [[ -e "$HOME/.path" ]]
then
	source "$HOME/.path"
else
	PATH='/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'
fi

if ((! $+commands[youtube-dl] ))
then
	echo "$NAME: 'youtube-dl' is required but not found in $PATH" \
	| tee -a "$HOME/Desktop/$NAME.errors.txt"

	exit 1
fi
	# This is the same file that we created in the Shortcut,
        #
	# Remember to change the name of the user!!!!
	#
        # If you change the filename in the Shortcut, change it here too
	#
INPUT="/Users/[user]/Library/Mobile Documents/youtube-dl/urls.txt"

if [[ ! -e "$INPUT" ]]
then
		# What happens if the script is run but the file does not exist?
		# We should just quit immediately
	echo "$NAME: The input file does not exist."
	exit 0
fi

if [[ ! -s "$INPUT" ]]
then
		# What happens if the script is run and the file exists but it is
		# zero bytes? We should just quit immediately
	echo "$NAME: The input file is empty."
	exit 0
fi

## Ok, so if we get here, the file exists and is not empty.

	# we're going to use this so we can remove the original file ASAP
	# in case another URL gets sent by another invocation of the Shortcut
TEMPFILE="$HOME/.Trash/dl-get.$$.$RANDOM.txt"

	# This will rename the original file to this temp file in the trash
mv -vf "$INPUT" "$TEMPFILE"

	# the 'egrep' line will look for any line that starts with 'http'
	# which will also match 'https' URLs, of course
	# and then it will process each line that starts with https
	# and ignore all of the other lines, including any blank lines.

egrep '^http' "$TEMPFILE" | while read line
do

        #now go get it!
		
	youtube-dl \
		--output "$HOME/Downloads/youtube/%(title)s-%(id)s.%(ext)s" \
		--restrict-filenames \
		--continue \
		--no-overwrites \
		"$line" &
done

exit 0
# EOF

Hazel then picks up the end result, puts it in a folder (same name) and transfers it to my Jellyfin library for viewing. I view these offline when I am on the road using infuse to download to the device and view.

Another option even geekier to setup, but easy to use, is to put metube in a docker container on your mac, just copy past the url there and have the end result processed by hazel as above.

so there you have it, options a-plenty :slight_smile:

2 Likes