dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

wmt (1673B)


      1 #!/bin/sh
      2 #                              ██
      3 #                             ░██
      4 #   ███     ██  ██████████   ██████
      5 #  ░░██  █ ░██ ░░██░░██░░██ ░░░██░
      6 #   ░██ ███░██  ░██ ░██ ░██   ░██
      7 #   ░████░████  ░██ ░██ ░██   ░██
      8 #   ███░ ░░░██  ███ ░██ ░██   ░░██
      9 #  ░░░    ░░░  ░░░  ░░  ░░     ░░
     10 # w e e k l y   m u s i c   t o o t
     11 
     12 # output of cmus-status-display script
     13 music_list="$HOME/.cmus/wmt.txt"
     14 
     15 [ -f ${music_list} ] || exit 1
     16 
     17 # toot command path
     18 toot="$HOME/src/warez/social_media/toot/bin/toot"
     19 
     20 # sort list by number of plays
     21 weekmusic=$(sort $music_list | uniq -c | sort -nr | \
     22 			awk '{$1=""; print $0}' | \
     23 			#tr '[:upper:]' '[:lower:]' | \
     24 			sed 's/^/\*\ /')
     25 
     26 # generate toot and count characters
     27 char=$(cat <<wmt | wc -m
     28 (automated) #weeklymusictoot
     29 
     30 this week i listened to:
     31 
     32 $weekmusic
     33 wmt
     34 )
     35 
     36 # if characters is more than 500 the toot will fail
     37 # we delete the last entry in the list until
     38 # there are less than 500 chars
     39 until [ ${char} -lt 500 ] ; do
     40 weekmusic=$(echo "$weekmusic" | sed '$d')
     41 cat <<wmt
     42 $weekmusic
     43 wmt
     44 char=$(cat <<wmt | wc -m
     45 (automated) #weeklymusictoot
     46 
     47 this week i listened to:
     48 
     49 $weekmusic
     50 wmt
     51 )
     52 sleep 1
     53 done
     54 
     55 # generate toot then delete list for next week
     56 # if it fails page me
     57 cat <<wmt | $toot post && rm -f ${music_list} || curl -d "wmt failed to send" https://pager.pyratebeard.net/wmt
     58 (automated) #weeklymusictoot
     59 
     60 this week i have been listening to:
     61 
     62 $weekmusic
     63 wmt