Advertisement
metalx1000

Get Song Lyrics - BASH Shell Script

Nov 2nd, 2017
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. domain="http://www.mldb.org"
  4. search="$domain/search?mq="
  5.  
  6. #color settings
  7. bold=`echo -en "\e[1m"`
  8. underline=`echo -en "\e[4m"`
  9. red=`echo -en "\e[31m"`
  10. aqua=`echo -en "\e[36m"`
  11. default=`echo -en "\e[39m"`
  12. RED=`echo -en "\e[41m"`
  13. AQUA=`echo -en "\e[46m"`
  14. DEFAULT=`echo -en "\e[49m"`
  15.  
  16. if [ "$1" == "" ]
  17. then
  18.   echo -n "${RED}Artist:${DEFAULT} "
  19.   read artist
  20. else
  21.   artist="$1"
  22. fi
  23.  
  24. wget -q "${search}${artist}" -O-|sed 's/<a/\n<a/g'|grep 'href="song'|while read line
  25. do
  26.   song="$(echo "$line"|cut -d\> -f2|cut -d\< -f1 )"
  27.   link="$(echo "$line"|cut -d\" -f2 )"
  28.  
  29.   echo "$song|$domain/$link"
  30. done > /tmp/lyrics.lst
  31.  
  32. mapfile -t list < /tmp/lyrics.lst
  33.  
  34. let x=0
  35. cat /tmp/lyrics.lst|while read line
  36. do
  37.   echo "$x - $(echo "$line"|cut -d\| -f1)"
  38.   let x++
  39. done
  40.  
  41. echo -n "${red}Select a Song#: ${default}"
  42. read n
  43.  
  44. echo "Getting Lyrics for $(echo ${list[$n]}|cut -d\| -f1)"
  45. wget -q -O- "$(echo ${list[$n]}|cut -d\| -f2)"|\
  46.   awk '/songtext/,/script/ { print }' |\
  47.   sed 's|</b>|-|g' |\
  48.   sed 's|<[^>]*>||g'|\
  49.   less
  50.  
  51. echo "Goodbye..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement