💾 Archived View for runjimmyrunrunyoufuckerrun.com › rc › yt captured on 2021-12-17 at 13:26:06.

View Raw

More Information

-=-=-=-=-=-=-

#!/bin/rc
# yt: download a video from youtube
# https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f/raw/76fae95c0898aabe155f22df558d3fd7f49f805f/youtube_formats.md
hget $1 | awk '
	BEGIN{
		RS = "\""
		tab[18] = "360p mp4"
		tab[22] = "720p mp4"
		tab[133] = "240p m4v"
		tab[134] = "360p m4v"
		tab[135] = "480p m4v"
		tab[136] = "720p m4v"
		tab[137] = "1080p m4v"
		tab[139] = "48kbps m4a"
		tab[140] = "128kbps m4a"
		tab[160] = "144p m4v"
		tab[242] = "240p webm"
		tab[243] = "360p webm"
		tab[244] = "480p webm"
		tab[247] = "720p webm"
		tab[248] = "1080p webm"
		tab[249] = "~50kbps opus"
		tab[250] = "~70kbps opus"
		tab[251] = "<=160kbps opus"
		tab[256] = "192kbps m4a"
		tab[258] = "384kbps m4a"
		tab[271] = "1440p webm"
		tab[272] = "4320p webm"
		tab[278] = "144p webm"
		tab[298] = "720p m4v"
		tab[299] = "1080p m4v"
		tab[302] = "720p webm"
		tab[303] = "1080p webm"
		tab[308] = "1440p webm"
		tab[313] = "2160p webm"
		tab[315] = "2160p webm"
		tab[330] = "144p webm"
		tab[331] = "240p webm"
		tab[332] = "360p webm"
		tab[333] = "480p webm"
		tab[334] = "720p webm"
		tab[335] = "1080p webm"
		tab[336] = "1440p webm"
		tab[337] = "2160p webm"
		tab[394] = "144p m4v"
		tab[395] = "240p m4v"
		tab[396] = "360p m4v"
		tab[397] = "480p m4v"
		tab[398] = "720p m4v"
		tab[399] = "1080p m4v"
		tab[400] = "1440p m4v"
		tab[401] = "2160p m4v"
		tab[402] = "4320p m4v"
	}
	/^http.*googlevideo.*itag=.*/{
		gsub(/\\u0026/, "\\&")
		gsub(/\\/, "")
		e = "/env/url" ++n
		print > e
		match($0, /itag=[0-9]+/)
		print "["n"] "tab[substr($0, RSTART+5, RLENGTH-5)]
	}
'
while(){
	echo -n 'format to download: '
	r = `{read}
	if(~ $r '' || ! test -r /env/url^$r){echo seeya!; exit}
	u = `{cat /env/url^$r}
	echo -n 'save path: '
	r = `{read}
	hget $u | tput -p > $r |[2] aux/statusmsg -t
}