metalx1000

dmusic

Feb 4th, 2018 (edited)
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.20 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #playlist File
  4. playlist="$HOME/.dmusic.m3u"
  5.  
  6. #wad dir
  7. WADS="$HOME/.doom/"
  8.  
  9. #playlist Url
  10. url='https://www.youtube.com/playlist?list=PLcUid3OP_4OVBK5JUVRshK25aIpuEWc-k'
  11.  
  12. #function
  13. func="$1"
  14.  
  15. function main(){
  16.   if [ "$func" = "update" ]
  17.   then
  18.     update
  19.   elif [ "$func" = "maps" ]
  20.   then
  21.     deutex -wadi $WADS/*.wad|grep -i "^map"|awk '{print $1}'|sort
  22.     echo "====================="
  23.     echo -n "Number of MAPS: "
  24.     deutex -wadi $WADS/*.wad|grep -i "^map"|awk '{print $1}'|sort|wc -l
  25.     exit
  26.   elif [ "$func" = "music" ]
  27.   then
  28.     music 100
  29.   else
  30.     play
  31.   fi
  32. }
  33.  
  34. function update(){
  35.   echo "Updating $playlist, please wait..."
  36.   youtube-dl --get-id "$url" $cookie|\
  37.     while read id;
  38.     do
  39.       #echo "https://www.youtube.com/watch?v=$id";
  40.       youtube-dl -g -f bestaudio $cookie "https://www.youtube.com/watch?v=$id";
  41.     done > $playlist
  42.   }
  43.  
  44. function music(){
  45.   if [ "$#" -lt "1" ]
  46.   then
  47.     vol="50"
  48.   else
  49.     vol="$1"
  50.   fi
  51.  
  52.   #tmux split "mpv --input-ipc-server=/tmp/mpvsocket --no-video --volume=$vol --shuffle \"$playlist\""
  53.   tmux split "mpv --input-ipc-server=/tmp/mpvsocket --no-video --volume=$vol --shuffle $HOME/music/dmusic/* "
  54.   #tmux split "mpv --input-ipc-server=/tmp/mpvsocket --no-video --volume=$vol --shuffle \"$url\""
  55. }
  56.  
  57. function game(){
  58.   wads="$(echo -n "-file ";find "$WADS" -iname "*.WAD"|while read wad;do echo "$wad";done |tr "\n" " ")"
  59.   dehs="$(find "$WADS" -iname "*.deh"|while read deh;do echo "-deh $wdeh";done |tr "\n" " ")"
  60.   echo "RUNNING: prboom-plus -nomusic $wads $deh"
  61.   if [ "$func" = "doom1" ];
  62.   then
  63.     echo "==============Playing Doom 1================"
  64.     prboom-plus -iwad /usr/share/games/doom/doom.wad -nomusic $wads $deh
  65.   elif [ "$func" = "plutonia" ] || [ "$func" = "p" ];
  66.   then
  67.     echo "==============Playing Doom 1================"
  68.     prboom-plus -iwad /usr/share/games/doom/plutonia.wad -nomusic
  69.   elif [ "$func" = "tnt" ] || [ "$func" = "t" ];
  70.   then
  71.     echo "==============Playing Doom 1================"
  72.     prboom-plus -iwad /usr/share/games/doom/tnt.wad -nomusic
  73.   else
  74.     prboom-plus -nomusic $wads $deh
  75.   fi
  76. }
  77.  
  78. function play(){
  79.   music
  80.   game
  81. }
  82.  
  83. main
  84. echo "Goodbye"
  85.  
Add Comment
Please, Sign In to add comment