bump to 0.0.3-dev:wq

This commit is contained in:
coolnsx
2024-06-19 10:34:54 +05:30
parent dd3a0dca14
commit a4fd55cae9
4 changed files with 88 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
domain="allanime.day"
run_file="${TMPDIR:-/tmp}/${0##*/}_run"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '2-5' | cut -c1).0.0.0 Safari/537.36"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '3-6' | cut -c1).0.0.0 Safari/537.36"
debug=$2
\cat << EOF > "$run_file"

View File

@@ -65,7 +65,7 @@ instagram() {
#main
link="$1"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '2-5' | cut -c1).0.0.0 Safari/537.36"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '3-6' | cut -c1).0.0.0 Safari/537.36"
case $(uname -o) in
*ndroid*)

155
fap-cli
View File

@@ -1,13 +1,5 @@
#!/bin/sh
c_red="\033[1;31m"
c_green="\033[1;32m"
c_yellow="\033[1;33m"
c_blue="\033[1;34m"
c_magenta="\033[1;35m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
help_text() {
while IFS= read -r line; do
printf "%s\n" "$line"
@@ -25,21 +17,25 @@ help_text() {
EOF
}
err() {
printf "$c_red%s$c_reset\n" "$*" >&2
info() {
#shellcheck disable=SC2059
printf "\033[2K\r\033[1;${2:-32}m${1}\033[0m"
}
get_query() {
[ -z "$*" ] && printf "%sSearch>%s " "$c_green" "$c_reset" && read -r query || query=$*
query=$(printf "%s" "$query" | tr " " "+")
ask() {
info "$1" "33"
}
err() {
info "$1\n" "31"
}
input() {
printf "$c_yellow Episode??(1-%s)>$c_reset " "$1"
ask " Episode??(1-$1)> "
read -r x
while [ -z "$x" ] || ! [ "$x" -eq "$x" ] 2>/dev/null || [ "$x" -lt "1" ] 2>/dev/null || [ "$x" -gt "$1" ] 2>/dev/null; do
err "Invalid choice"
printf "$c_yellow Episode??(1-%s)>$c_reset " "$1"
ask " Episode??(1-$1)> "
read -r x
done
ep_no=$x
@@ -48,74 +44,98 @@ input() {
stream() {
case $player_fn in
vlc)
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$2" >/dev/null 2>&1 || setsid -f "$player_fn" --http-referrer="$base_url" "$1" >/dev/null 2>&1
;;
mpv)
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 || setsid -f "$player_fn" "$1" --referrer="$base_url" --force-media-title="$2" >/dev/null 2>&1
;;
vlc) setsid -f "$player_fn" --http-referrer="$base_url" "$1" >/dev/null 2>&1 ;;
mpv) setsid -f "$player_fn" "$1" --referrer="$base_url" --force-media-title="$2" >/dev/null 2>&1 ;;
vlc_android) am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 ;;
mpv_android) am start --user 0 -a android.intent.action.VIEW -d "$1" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$2" >/dev/null 2>&1 ;;
esac
}
download() {
printf "${c_blue}Downloading %s${c_reset}\n" "$2"
info "Downloading $1" "34"
case $1 in
*m3u8)
hls -n 300 -ro "$download_dir/$2" "$1"
;;
*)
aria2c --summary-interval=0 -x 16 -s 16 --referer="$base_url" "$1" --dir=$download_dir -o "$2.mp4" --download-result=hide
;;
*m3u8) $terminal hls -n 300 -ro "$download_dir/$2" "$1" ;;
*) $terminal aria2c --summary-interval=0 -x 16 -s 16 --referer="$base_url" "$1" -d "$download_dir" -o "$2.mp4" --download-result=hide ;;
esac
}
get_show() {
printf "${c_blue}Searching query.."
results=$(curl -s "$base_url/?s=$query" | sed -nE 's_^[[:space:]]*<a href="https://hentaimama.io/tvshows/(.*)/">.$_\1_p')
[ -z "$results" ] && printf "\33[2K\r${c_red}No search results found${c_reset}" && exit 0
printf "\33[2K\r${c_green}Results found\n"
result=$(printf "%s" "$results" | fzf --layout="reverse" --border --height=10)
info "Searching query.." "34"
results=$(search | fzf --bind="change:reload:$run_file {q} 1" --prompt="Search: " )
[ -z "$results" ] && err "No search results found" && exit 0
info ""
result=$(printf "%s" "$results" | fzf --layout="reverse" --border --height=10 -1)
[ -z "$result" ] && err "No hentai selected" && exit 0
printf "${c_magenta}selected $result\n${c_blue}Fetching episode list"
ep_list=$(curl -s "$base_url/tvshows/$result/" | sed -nE 's_^[[:space:]]*<a href="https://hentaimama.io/(.*)/">.$_\1_p' | tac)
info "selected $result\n" "35"
info "Fetching Episodes List.." "34"
ep_list=$(curl -sA "$agent" "$base_url/tvshows/$result/" | sed -nE 's_^[[:space:]]*<a href="https://hentaimama.io/(.*)/">.$_\1_p' | tac)
noofeps=$(printf "%s\n" "$ep_list" | wc -l)
printf "\33[2K\r${c_green}Episodes list fetched\n"
[ "$noofeps" -eq 1 ] && ep_no=1 || input "$noofeps"
ep_no=1
[ "$noofeps" -gt 1 ] && input "$noofeps"
get_ep_link
}
get_ep_link() {
tput clear
printf "${c_blue}Loading Episode $ep_no"
info "Loading Episode $ep_no" "34"
ep_id=$(printf "%s" "$ep_list" | sed -n "${ep_no}p")
id=$(curl -s "$base_url/$ep_id/" | sed -nE "s/.*?p=(.*)'.*/\1/p")
id=$(curl -sA "$agent" "$base_url/$ep_id/" | sed -nE "s/.*?p=(.*)'.*/\1/p")
display=$(printf "%s" "$ep_id" | cut -d'/' -f2- | tr "-" " ")
[ -z "$id" ] && printf "\33[2K\r${c_red}Episode doesn't exist on this site${c_reset}" || play_link
[ -z "$id" ] && err "Episode doesn't exist on this site" && return 1
play_link
}
play_link() {
printf "\33[2K\r${c_blue}Fetching video link"
data="$(curl -s "$(curl -s "$base_url/wp-admin/admin-ajax.php" -d "action=get_player_contents&a=$id" -H "X-Requested-With:XMLHttpRequest" | tr -d '\\' | sed -nE 's/.*src="(.*)" width.*,.*/\1/p')")"
info "Fetching Video Link" "34"
data="$(curl -sA "$agent" "$(curl -sA "$agent" "$base_url/wp-admin/admin-ajax.php" -d "action=get_player_contents&a=$id" -H "X-Requested-With:XMLHttpRequest" | sed 's/\\//g' | sed -nE 's/.*src="(.*)" width.*,.*/\1/p')")"
video_link="$(printf "%s" "$data" | sed -nE 's/[[:space:]]*<source src="(.*)" typ.*/\1/p')"
# trying again
[ -z "$video_link" ] && video_link="$(printf "%s" "$data" | sed -nE 's/[[:space:]]*file: "(.*)".$/\1/p')"
if [ -z "$video_link" ]; then
printf "\33[2K\r${c_red}Video Url not found${c_reset}\n"
[ -z "$video_link" ] && err "Video Url not found" && return 1
info "\n$video_link\n"
if [ "$is_download" -eq "0" ]; then
stream "$video_link" "$display"
else
printf "\33[2K\r${c_green}Video link fetched${c_reset}\n"
printf "\n%s\n" "$video_link"
if [ "$is_download" -eq "0" ]; then
stream "$video_link" "$display"
else
download "$video_link" "$display"
fi
download "$video_link" "$display"
fi
[ "$noofeps" -eq 1 ] && exit 0
}
trap "exit 0" INT HUP
base_url="https://hentaimama.io"
player_fn="mpv"
is_download=0
download_dir=.
download_dir='.'
run_file="${TMPDIR:-/tmp}/${0##*/}_run"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '3-6' | cut -c1).0.0.0 Safari/537.36"
case $(uname -o) in
*ndroid*)
download_dir="/sdcard"
player_fn="mpv_android"
alt_fn="vlc_android"
;;
*)
download_dir="$HOME/Downloads"
player_fn="mpv"
alt_fn="vlc"
[ -t 1 ] || terminal="${TERMINAL:-foot} -e"
;;
esac
\cat << EOF > "$run_file"
search() { curl -s -A "$agent" "$base_url/?s=\$1" | sed -nE 's_^[[:space:]]*<a href="https://hentaimama.io/tvshows/(.*)/">.\$_\1_p'; }; [ -n "\$2" ] && search "\$1"
EOF
chmod +x "$run_file"
# shellcheck disable=SC1091,SC1090
. "$run_file"
while getopts 'dhp:v' OPT; do
case $OPT in
@@ -127,7 +147,7 @@ while getopts 'dhp:v' OPT; do
download_dir=$OPTARG
;;
v)
player_fn="vlc"
player_fn=$alt_fn
;;
*)
help_text
@@ -137,33 +157,27 @@ while getopts 'dhp:v' OPT; do
done
shift $((OPTIND - 1))
get_query "$*"
get_show
while :; do
printf "\n${c_green}Currently playing %s/%s\n" "$display" "$noofeps"
[ "$ep_no" != "$noofeps" ] && printf "$c_yellow(%s) %s$c_reset\n" "n" "next"
[ "$ep_no" != "1" ] && printf "$c_cyan(%s) %s$c_reset\n" "p" "previous"
printf "$c_magenta(%s) %s$c_reset\n" "d" "download current video"
printf "$c_blue(%s) %s$c_reset\n" "e" "select episode"
printf "$c_red(%s) %s$c_reset\n" "q" "exit"
printf "${c_green}>$c_reset "
read choice
info "\nCurrently playing $display/$noofeps\n"
[ "$ep_no" != "$noofeps" ] && info "(n) next\n" "33"
[ "$ep_no" != "1" ] && info "(p) previous\n" "36"
info "(e) select episode\n" "34"
info "(q) exit\n" "31"
ask "> "
read -r choice
case $choice in
d)
download "$video_link" "$display"
;;
n)
ep_no=$((ep_no + 1))
[ "$ep_no" -gt "$noofeps" ] && err "Episode out of range" && ep_no=$((ep_no - 1)) || get_ep_link
[ "$((ep_no + 1))" -gt "$noofeps" ] && err "Episode out of range" && continue
: $((ep_no += 1))
;;
p)
ep_no=$((ep_no - 1))
[ "$ep_no" -lt "1" ] && err "Episode out of range" && ep_no=$((ep_no + 1)) || get_ep_link
[ "$((ep_no - 1))" -lt "1" ] && err "Episode out of range" && continue
: $((ep_no -= 1))
;;
e)
input "$noofeps"
get_ep_link
;;
q)
break
@@ -172,4 +186,5 @@ while :; do
err "invalid choice"
;;
esac
get_ep_link
done

View File

@@ -329,7 +329,7 @@ base_url="https://music.youtube.com"
[ -d "$logdir" ] || mkdir "$logdir"
[ -p "$presence" ] || mkfifo "$presence"
cookie="$logdir/cookies"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '3-6' | cut -c1).0.0.0 Safari/537.36"
#call this script by script-name "function_name" "query"
[ -z "$1" ] && help "$@"