metalx1000

Music Playlist from myfreemp3

Apr 30th, 2017
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.46 KB | None | 0 0
  1. #!/bin/bash
  2. #description     :This script will create a music playlist and play it
  3. #author      :Kris Occhipinti <http://FilmsByKris.com>
  4. #date            :20170501
  5. #version         :0.2
  6. #License     :GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt    
  7.  
  8. site="https://myfreemp3.click"
  9. url="https://myfreemp3.click/api/search.php?callback=jQuery21301101852661060918_1493583931877"
  10. q="$1"
  11. pl="/tmp/music.m3u"
  12. l="==============="
  13. tmp="/tmp/music.tmp"
  14. info="/tmp/music.info"
  15.  
  16. #set colors
  17. bold=`echo -en "\e[1m"`
  18. red=`echo -en "\e[31m"`
  19. normal=`echo -en "\e[0m"`
  20.  
  21. #remove tmp files
  22. rm "$tmp $info $pl" 2>/dev/null
  23.  
  24. if [ $# -lt 1 ]
  25. then
  26.   echo "Sorry, no input given..."
  27.   echo "try something like this:"
  28.   echo "$0 'nine inch nails' shuff"
  29.   echo "Goodbye..."
  30.   exit 1
  31. fi
  32.  
  33. echo "${bold}$l Creating Playlist $l${normal}"
  34.  
  35. curl "$url" -H "origin: $site" -H 'accept-encoding: gzip, deflate, br' -H 'x-requested-with: XMLHttpRequest' -H 'accept-language: en-US,en;q=0.8' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'accept: text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01' -H 'referer: https://myfreemp3.click/' -H 'authority: myfreemp3.click' -H 'cookie: __cfduid=da06ebcf2a76fa5a4b2ae6842f589d93f1492027491; __atssc=google%3B1; musicLang=en; __utmt=1; __utma=245448472.761302065.1492027494.1493036598.1493583571.4; __utmb=245448472.2.10.1493583571; __utmc=245448472; __utmz=245448472.1492027494.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=1%7C15%2C1%7C16%2C1%7C17%2C2%7C18; __atuvs=590646d3f092f1aa001' --data "q=$q&sort=2&count=300&performer_only=0" --compressed -o "$tmp"
  36.  
  37. cat "$tmp"|\
  38.   sed 's/{/\n{/g'|\
  39.   sed 's/,/,\n/g'|\
  40.   grep "url"|\
  41.   cut -d\" -f4|\
  42.   sed 's/\\//g' > "$pl"
  43.  
  44. #get url and song title into info file
  45. cat "$tmp"|\
  46.   sed 's/{/\n{/g'|\
  47.   sed 's/,/,\n/g'|\
  48.   grep -e "title" -e "url"|\
  49.   cut -d\" -f4|\
  50.   sed 's/\\//g'|\
  51.   sed ':r;$!{N;br};s/\nhttp/|http/g' > "$info"
  52.  
  53. #shuffle playlist
  54. if [ "$2" == "shuff" ]
  55. then
  56.   echo "Shuffling Songs"
  57.   shuf "$pl" > /tmp/shuf
  58.   mv /tmp/shuf "$pl"
  59. fi
  60.  
  61. #display first 20 song titles
  62. echo "${bold}${red}"
  63. head -n20 "$pl"|\
  64. while read line;
  65. do
  66.   grep "$line" "$info"|cut -d\| -f1;
  67. done
  68. echo "${normal}"
  69.  
  70. #play playlist
  71. mpv --no-ytdl --no-audio-display "$pl"
Add Comment
Please, Sign In to add comment