Advertisement
metalx1000

Daily Audio Bible DAB Player for Linux/Android/Termux/MPV

Jan 16th, 2019
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. #!/data/data/com.termux/files/usr/bin/bash
  2.  
  3. dir="$HOME/downloads"
  4.  
  5. function get_new(){
  6.   clear
  7.   echo "No Files Found"
  8.   echo "Streaming newest..."
  9.   url="https://player.dailyaudiobible.com/dab"
  10.   m4a="$(wget -qO- "$url"|grep m4a|sed 's/"url":"/\n/g'|tail -n1|cut -d\" -f1|sed 's|\\/|/|g')"
  11.   echo "$m4a"
  12.   mpv --speed 1.77 "$m4a"
  13.   exit
  14. }
  15.  
  16. #files=( $dir/*dailyaudiobible* )
  17. ls $dir/*dailyaudiobible* || get_new
  18.  
  19. files=($( ls $dir/*dailyaudiobible* ))
  20. let x=0;
  21.  
  22. if [ "${#files[@]}" -eq "1" ]
  23. then
  24.   echo "One File Found"
  25.   f="${files[0]}"
  26.   echo "Playing $f"
  27. else
  28.  
  29.   echo "${files[@]} files found."
  30.   for i in "${files[@]}"
  31.   do
  32.  
  33.     t="$(echo "$i"|rev|cut -d\_ -f1|rev)"
  34.     echo "$x)$t"
  35.     let x++
  36.   done
  37.  
  38.   echo -n "Select a number: "
  39.   read f
  40.  
  41.   #exit if no option is selected
  42.   if [ "$f" = "" ];then exit 0;fi
  43.  
  44.   f="${files[f]}"
  45.  
  46. fi
  47.  
  48. t="$(echo "$f"|rev|cut -d\_ -f1|rev)"
  49. echo "Playing $t"
  50. mpv --speed 1.77 $f
  51.  
  52. echo "Would you like to remove this file? (Y/n)"
  53. read del
  54.  
  55.  
  56. if [ "${del^^}" == "Y" ] || [ "$del" == "" ]
  57. then
  58.   rm "$f" && echo "$f had been deleted."
  59. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement