brtv-generate-playlist.sh (922B)
1 #!/bin/sh 2 # supply hashtags.txt as stdin 3 # output is a plaintext playlist with urls to memes and title slides 4 # titles and image memes are served on a separate host ($title_image_host) 5 6 7 ### CONFIGURATION START 8 9 # other host to serve titles and images converted to videos 10 title_image_host="gopher://bitreich.org" 11 title_dir="tv/title" 12 img2vid_dir="tv/img2vid" 13 video_ext="webm" 14 15 ### CONFIGURATION END 16 17 18 regeximatch() { 19 printf '%s' "$1" | grep -iEq "$2" 20 } 21 22 add_title() { 23 printf '%s/9/%s/%s\n' "$title_image_host" "$title_dir" "${1#\#}.${video_ext}" 24 } 25 26 while read -r tag url; do 27 28 if regeximatch "$url" '\.(mkv|webm|mp4)$'; then 29 add_title "$tag" 30 printf '%s\n' "$url" 31 elif regeximatch "$url" '\.(jpg|jpeg|png|gif)$'; then 32 add_title "$tag" 33 printf '%s/9/%s/%s\n' "$title_image_host" "$img2vid_dir" "${tag#\#}.${video_ext}" 34 else 35 # skip mpv-incompatible formats that are not converted to videos 36 continue 37 fi 38 done