Advertisement
metalx1000

Stream Audio Books in your BASH Shell

Feb 18th, 2024
1,706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.58 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2024  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18.  
  19. [[ $1 ]] && q="$*" || read -p "Enter Book Title: " q
  20.  
  21. function get_list(){                                                                                                        
  22.   curl -s 'https://101audiobooks.net/wp-admin/admin-ajax.php' \
  23.   --data-raw "s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}&origin_id=1331" \
  24.   --compressed|recode html..utf8
  25. }
  26.  
  27. list="$(get_list)"
  28. books="$(echo "$list"|grep "Listen to: "|sed "s/^[ \t]*//"|sed 's/Listen to: //g;s/ Audiobook »//g')"
  29.  
  30. book="$(echo "$books"|fzf --prompt="Select a Book: ")"
  31. [[ $book ]] || exit
  32.  
  33. url="$(echo "$list"|grep -B1 "$book"|grep http|cut -d\" -f2|head -n1)"
  34. [[ $url ]] || exit
  35. echo "$url"
  36.  
  37. mp3="$(wget -qO- "$url"|grep mp3|tr ">" "\n"|grep "^http"|cut -d\< -f1|fzf)"
  38. [[ $mp3 ]] || exit
  39. mpv "$mp3"
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement