|
Right now I'm using these kind of shitty shell scripts to download the videos, ls to list them, and mpv on the command line to play them. These use a file called "channels" which contains YouTube channel URLs and space-separated tags, like this: https://www.youtube.com/channel/UClaEdLrmti779-tyovta8zw grandpa amu hardware carpentry hacking
https://www.youtube.com/channel/UCLt9kIslIa1ffiM8A04KORw wm levsha hardware hacking
Here are the scripts, slightly cleaned up:snarf: #!/bin/sh
echo "snarf $@"
exec python3 ../youtube-dl -f '[height<769]' -i -r 1M -R 1 \
--sleep-interval "${wait-227}" --max-filesize "${max_filesize-242m}" \
--no-mtime --playlist-end ${n-5} --write-info-json --add-metadata \
--write-description --write-thumbnail --write-auto-sub \
--write-sub --sub-lang en,es "$@"
snarf-tags: #!/bin/sh
exec ./snarf $(./tag "$@" | shuf | sed 's,$,/videos,')
search: #!/bin/sh
exec ./snarf ytsearch10:"$(echo "$@" | sed 's, ,+,g')"
resnarf: #!/bin/sh
: ${1?Usage: $0 foo.mp4.part}
# example: garbage\ stuff\ -zKLMCO0-How.mp4.part
for x in "$@"; do
x=$(echo "$x" | perl -ne 'm,(.{11})\.mp4,; print $1')
./snarf "https://youtu.be/$x"
done
tag: #!/usr/bin/env python3
import sys
def match(args, line):
return (not any('-' + word in args for word in line)
and not any(word not in line for word in args if word[0] != '-'))
def main(args, input, output):
for line in input:
words = line.split()
if match(args, words):
output.write(words[0] + "\n")
if __name__ == '__main__':
main(sys.argv[1:], open('channels'), sys.stdout)
So my searchbar is "wait=3 ./search japanese hornets" or "./search electrochemical machining advances", and periodically I run "./snarf-tags" to download any new videos over the next few hours, which I can then see with "ls -lart ./*4". And if I want to know where some great search-result video came from so I can add it to the list of channels, why, that's "jq -r .uploader_url Romanes\ Eunt\ Domus\ EXPLAINED\ _\ Monty\ Python\'s\ Life\ of\ Brian\ •\ Fun\ with\ Latin-UfH6gjxTTgE.info.json", which sounds horrible but it's really more like ^Rjq^A M-f M-f M-f ^K Ro<TAB>.Suggested videos and thumbnail display, not to mention buttons to press for the above things, would be a welcome addition, but thumbnail display is difficult in the terminal. Also, it would be pretty great to have a way to not redownload a video after I deleted it, and for youtube-dl to not wait the 227 seconds before deciding not to download a video because it's a four-hour snoozefest recorded livestream. |