ref: 05923b4301e65e7ed47a95b871d02a943f383865
dir: /youtube.md/
Youtube ======= Commit [treason](https://git.sr.ht/~ft/treason). It supports H.264, VP8, VP9 and AV1. *NOTE* one does not simply commit treason on anything other than AMD64 or 386. No videos for Raspi users, sorry. You can still play audio only on other arches though. Install [youtubedr](https://github.com/ftrvxmtrx/youtube): 9fs ftrv.se gunzip < /n/ftrv.se/bin/youtubedr.$objtype.gz > $home/bin/$objtype/youtubedr chmod +x $home/bin/$objtype/youtubedr hget https://curl.haxx.se/ca/cacert.pem > /sys/lib/tls/ca.pem `youtubedr` may fail with "error parsing signature tokens". Not much can be done here until the upstream incorporates some logic that `youtube-dl` has. For now, some of the videos will just fail to download. *BUMMER*. ## Playing just audio alone mcfs -t 1 `"{youtubedr download -q 140 -d /tmp -o audio.mp4 ybGOT4d2Hs8} | audio/aacdec > /dev/audio ## Playing video and/or audio The easiest way to play ANY video on Youtube is to use H.264 "baseline" stream. It's of pretty bad quality image-wise, but contains audio in the container itself and doesn't require too much CPU resources. treason `"{youtubedr download -q 18 -d /tmp -o _vid.mp4 ybGOT4d2Hs8}; rm -f /tmp/_vid.mp4 If you want to find the best possible format, use the following script: #!/bin/rc rfork ne vitag=`{youtubedr info $"1 | awk ' /av01/ { tags[ntags++] = $2 if($2 == "398"){ # prefer hd720 tags[0] = $2 exit } } END { if(ntags > 0) print tags[0] } '} if(~ $#vitag 0) treason `"{youtubedr download -q 18 -d /tmp -o _vid.mp4 $"1} if not treason -a `"{youtubedr download -q 140 -d /tmp -o _aud.mp4 $"1} \ `"{youtubedr download -q $vitag -d /tmp -o _vid.mp4 $"1} #rm -f /tmp/_^(aud vid)^.mp4 *TODO* This script should be extended to choose best format based on preferences (resolution) and CPU resources. You can put that script to `$home/bin/rc/youtube` and add a plumb rule for Youtube URLs, right *before* `include basic`: type is text data matches 'https://(www.)?youtube[^ ]+' plumb start window youtube ''''$0'''' ## Caveats Many. Patches welcome. ## Support sigrid @ `#cat-v`.