URI: 
       brtv-generate-playlist.sh - bitreich-tv - Meme TV encoding and streaming
  HTML git clone git://bitreich.org/bitreich-tv git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-tv
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR LICENSE
       ---
       brtv-generate-playlist.sh (1065B)
       ---
            1 #!/bin/sh
            2 # supply hashtags.txt as stdin
            3 # output is a plaintext playlist with urls to memes and title slides
            4 
            5 
            6 ### CONFIGURATION START
            7 
            8 # other host to serve titles and images converted to videos
            9 title_image_host="gopher://bitreich.org"
           10 title_dir="tv/title"
           11 img2vid_dir="tv/img2vid"
           12 video_ext="webm"
           13 interludeurl="${title_image_host}/9/tv/tv-interlude.webm"
           14 interludeoccur=5  # percentage of occurence, set to 0 to disable
           15 
           16 ### CONFIGURATION END
           17 
           18 
           19 regeximatch() {
           20         printf '%s' "$1" | grep -iEq "$2"
           21 }
           22 
           23 add_title() {
           24         printf '%s/9/%s/%s\n' "$title_image_host" "$title_dir" "${1#\#}.${video_ext}"
           25 }
           26 
           27 while read -r tag url; do
           28                 
           29         if regeximatch "$url" '\.(mkv|webm|mp4)$'; then
           30                 add_title "$tag"
           31                 printf '%s\n' "$url"
           32         elif regeximatch "$url" '\.(jpg|jpeg|png|gif)$'; then
           33                 add_title "$tag"
           34                 printf '%s/9/%s/%s\n' "$title_image_host" "$img2vid_dir" "${tag#\#}.${video_ext}"
           35         else
           36                 # skip mpv-incompatible formats that are not converted to videos
           37                 continue
           38         fi
           39         if test $(( RANDOM / 327 )) -lt "$interludeoccur"; then
           40                 printf '%s\n' "${interludeurl}"
           41         fi
           42 done