brtv-generate-theme-channels.sh (625B)
1 #!/bin/sh 2 # generate channels where tags begin with a common word 3 # specify hashtags.txt path as $1 and optionally specify cutoff value as $2 4 5 die() 6 { 7 printf '%s: error: %s\n' "${0##*/}" "$1" >&2 8 exit 1 9 } 10 11 if [ $# -lt 1 ] || [ ! -r "$1" ]; then 12 die 'pass hashtags.txt path as first argument' 13 fi 14 15 awk -v cutoff="${2:-25}" ' 16 /^#[A-z0-9]+-.* / { 17 split($1, tagwords, "-") 18 tags[tagwords[1]]++ 19 } 20 END { 21 for (tag in tags) 22 if (tags[tag] >= cutoff) 23 print tag 24 } 25 ' "${1}" | while read -r tag; do 26 grep -E "^${tag}" "${1}" | \ 27 sort -R | \ 28 bin/brtv-generate-playlist.sh | \ 29 bin/brtv-playlist-to-m3u.sh > "${tag#\#}.m3u" 30 done