CCCPaste

Stream Audio Books in your BASH Shell

#!/bin/bash
###################################################################### 
#Copyright (C) 2024  Kris Occhipinti
#https://filmsbykris.com

#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation version 3 of the License.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see .
###################################################################### 

[[ $1 ]] && q="$*" || read -p "Enter Book Title: " q

function get_list(){                                                                                                         
  curl -s 'https://101audiobooks.net/wp-admin/admin-ajax.php' \
  --data-raw "s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}&origin_id=1331" \
  --compressed|recode html..utf8
}

list="$(get_list)"
books="$(echo "$list"|grep "Listen to: "|sed "s/^[ \t]*//"|sed 's/Listen to: //g;s/ Audiobook »//g')"

book="$(echo "$books"|fzf --prompt="Select a Book: ")"
[[ $book ]] || exit

url="$(echo "$list"|grep -B1 "$book"|grep http|cut -d\" -f2|head -n1)"
[[ $url ]] || exit
echo "$url"

mp3="$(wget -qO- "$url"|grep mp3|tr ">" "\n"|grep "^http"|cut -d\< -f1|fzf)"
[[ $mp3 ]] || exit
mpv "$mp3"