It's 2016; why are we using ColdFusion?!

This commit is contained in:
coolnsx
2024-06-20 14:39:05 +05:30
parent 53d9a412a2
commit f4ee1b8859
4 changed files with 45 additions and 48 deletions

View File

@@ -5,7 +5,7 @@ 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"
debug=$2
\cat << EOF > "$run_file"
\cat <<EOF >"$run_file"
search() { curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode 'query=query(\$search: SearchInput \$limit: Int \$page: Int \$translationType: VaildTranslationTypeEnumType \$countryOrigin: VaildCountryOriginEnumType) { shows( search: \$search limit: \$limit page: \$page translationType: \$translationType countryOrigin: \$countryOrigin ) {edges { _id name lastEpisodeInfo __typename}}}' --data-urlencode 'variables={"search":{"sortBy":"Recent","allowAdult":true,"allowUnknown":true,"query":"'"\$1"'"},"limit":40,"page":1,"translationType":"sub","countryOrigin":"ALL"}' | sed 's|Show|\n|g' | sed 's|__typename|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p'; }; [ -n "\$2" ] && search "\$1"
EOF

View File

@@ -18,24 +18,24 @@ notify_linux() {
notify-send -e "$1" -h "string:x-canonical-private-synchronous:${0##*/}"
}
conv_to_octal(){
conv_to_octal() {
base=$2
i=0
res=0
for key in $(printf "%s" "$1" | rev | sed 's/./&\n/g'); do
if [ "$key" -ne 0 ];then
if [ "$key" -ne 0 ]; then
j=$i
tmp=1
while [ "$j" -ne 0 ];do
while [ "$j" -ne 0 ]; do
: $((tmp *= base))
: $((j-=1))
: $((j -= 1))
done
res=$((res + (key * tmp)))
fi
: $((i+=1))
: $((i += 1))
done
res=$(printf '%03o' "$((res-${3}))")
res=$(printf '%03o' "$((res - ${3}))")
#shellcheck disable=SC2059
printf "\\$res" | sed 's/[\/&]/\\&/g'
}
@@ -48,15 +48,15 @@ instagram() {
n=$(printf "%s" "$response" | sed -n '3p')
t=$(printf "%s" "$response" | sed -n '4p')
e=$(printf "%s" "$response" | sed -n '5p')
printf '%s' "$n" | cut -c-"$e" | sed 's/./&\n/g' | tr -s '\n' | nl -nln -v0 | sed -nE 's|^([0-9]*)[[:space:]]*(.*)|s\/\2\/\1\/g|p' > "$sed_file"
printf 's/%s/\\n/g' "$(printf "%s" "$n" | cut -c"$((e+1))")" >> "$sed_file"
printf '%s' "$n" | cut -c-"$e" | sed 's/./&\n/g' | tr -s '\n' | nl -nln -v0 | sed -nE 's|^([0-9]*)[[:space:]]*(.*)|s\/\2\/\1\/g|p' >"$sed_file"
printf 's/%s/\\n/g' "$(printf "%s" "$n" | cut -c"$((e + 1))")" >>"$sed_file"
data=$(printf "%s" "$response" | head -1 | sed -f "$sed_file" | sed -n '1200,$p')
info "Decoding JS" "Instagram" "$2"
printf "" > "$sed_file"
printf "" >"$sed_file"
for num in $(printf "%s" "$data" | sort -u); do
printf 's/^%s$/%s/g\n' "$num" "$(conv_to_octal "$num" "$e" "$t")" >> "$sed_file" &
printf 's/^%s$/%s/g\n' "$num" "$(conv_to_octal "$num" "$e" "$t")" >>"$sed_file" &
done
wait
@@ -90,9 +90,9 @@ case "$link" in
res=0
enc_char="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
table=$(printf "%s" "$enc_char" | sed 's/\(.\)/\1\n/g' | nl -v0 | tr '\t' ':' | tr -d ' ')
for key in $(printf "%s" "$id" | sed -e 's/\(.\)/\1\n/g');do
value=$(printf "%s" "$table" | sed -nE "s/([^:]*):$key/\1/p")
res=$((res*64+value))
for key in $(printf "%s" "$id" | sed -e 's/\(.\)/\1\n/g'); do
value=$(printf "%s" "$table" | sed -nE "s/([^:]*):$key/\1/p")
res=$((res * 64 + value))
done
info "Fetching Video URL" "$app" "$id"

35
fap-cli
View File

@@ -42,19 +42,8 @@ input() {
unset x
}
stream() {
case $player_fn in
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 ;;
mpv_android) am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 ;;
vlc_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() {
info "Downloading $1" "34"
info "Downloading $2" "34"
case $1 in
*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 ;;
@@ -63,14 +52,14 @@ download() {
get_show() {
info "Searching query.." "34"
results=$(search | fzf --bind="change:reload:$run_file {q} 1" --prompt="Search: " )
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
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)
ep_list=$(curl -sA "$agent" "$base_url/tvshows/$result/" | sed -nE "s_^[[:space:]]*<a href=\"$base_url/(.*)/\">.\$_\1_p" | tac)
noofeps=$(printf "%s\n" "$ep_list" | wc -l)
ep_no=1
[ "$noofeps" -gt 1 ] && input "$noofeps"
@@ -98,7 +87,15 @@ play_link() {
[ -z "$video_link" ] && err "Video Url not found" && return 1
info "\n$video_link\n"
([ "$is_download" -eq "0" ] && stream "$video_link" "$display") || download "$video_link" "$display"
case $player_fn in
vlc) setsid -f "$player_fn" --http-referrer="$base_url" "$video_link" >/dev/null 2>&1 ;;
mpv) setsid -f "$player_fn" "$video_link" --referrer="$base_url" --force-media-title="$display" >/dev/null 2>&1 ;;
mpv_android) am start --user 0 -a android.intent.action.VIEW -d "$video_link" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 ;;
vlc_android) am start --user 0 -a android.intent.action.VIEW -d "$video_link" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$video_link" >/dev/null 2>&1 ;;
download) $player_fn "$video_link" "$display" ;;
esac
[ "$noofeps" -eq 1 ] && exit 0
}
@@ -124,8 +121,8 @@ case $(uname -o) in
;;
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"
\cat <<EOF >"$run_file"
search() { curl -s -A "$agent" "$base_url/?s=\$1" | sed -nE 's_^[[:space:]]*<a href="$base_url/tvshows/(.*)/">.\$_\1_p'; }; [ -n "\$2" ] && search "\$1"
EOF
chmod +x "$run_file"
@@ -136,10 +133,10 @@ chmod +x "$run_file"
while getopts 'dhp:v' OPT; do
case $OPT in
d)
is_download=1
player_fn="download"
;;
p)
is_download=1
player_fn="download"
download_dir=$OPTARG
;;
v)

View File

@@ -65,9 +65,9 @@ cleanup_shit() {
get_cookies() {
# the user has firefox installed
if [ ! -f "$HOME/.config/google-chrome/Default/Cookies" ];then
if [ ! -f "$HOME/.config/google-chrome/Default/Cookies" ]; then
cp "$(find "$HOME/.mozilla" -type f -iname 'cookies.sqlite' | head -1)" "$logdir/cookies.sqlite"
sqlite3 "$logdir/cookies.sqlite" "SELECT name, value FROM moz_cookies WHERE host='.youtube.com' and name NOT like 'ST-%';" | tr '|\n' '=;' > "$cookie"
sqlite3 "$logdir/cookies.sqlite" "SELECT name, value FROM moz_cookies WHERE host='.youtube.com' and name NOT like 'ST-%';" | tr '|\n' '=;' >"$cookie"
rm "$logdir/cookies.sqlite"
return 0
fi
@@ -168,8 +168,8 @@ set_activity() {
}
start_rich_presence() {
rm -f "$handshook" > /dev/null
tail -f "$presence" | nc -U "$discord_ipc" > "/tmp/ipclog"
rm -f "$handshook" >/dev/null
tail -f "$presence" | nc -U "$discord_ipc" >"/tmp/ipclog"
}
update_rich_presence() {
@@ -179,14 +179,14 @@ update_rich_presence() {
#start=$(date +%s)
#payload='{"cmd": "SET_ACTIVITY", "args": {"activity": {"details": "'$(printf "%s" "$title" | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')'", "state": "'$(printf "%s" "$title" | sed 's_.* - __;s| $||')'", "timestamps": {"start": '"$start"',"end": '"$((start + dur))"'}, "assets": {"large_image": "https://i.ytimg.com/vi/'$id'/mqdefault.jpg","large_text":"Checkmate Premium Users"},"buttons": [{"label":"Listen Song", "url": "https://music.youtube.com/watch?v='$id'"}]},"pid":786}, "nonce": "1"}' #pid needs to be set and constant so discord knows which application to update
payload='{"cmd": "SET_ACTIVITY", "args": {"activity": {"details": "'$(printf "%s" "$title" | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')'", "state": "'$(printf "%s" "$title" | sed 's_.* - __;s| $||')'", "assets": {"large_image": "https://i.ytimg.com/vi/'$id'/mqdefault.jpg","large_text":"Checkmate Premium Users","small_image":"https://upload.wikimedia.org/wikipedia/commons/7/73/Mpv_logo_%28official%29.png"},"buttons": [{"label":"Listen Song", "url": "https://music.youtube.com/watch?v='$id'"}]},"pid":786}, "nonce": "'$(date +%s%N)'"}' #pid needs to be set and constant so discord knows which application to update
if [ ! -e "$handshook" ];then
if [ ! -e "$handshook" ]; then
handshake='{"v":1,"client_id":"'$presence_client_id'"}'
# handshake with opcode
printf "\\000\\000\\000\\000\\$(printf "%03o" "${#handshake}")\\000\\000\\000%s" "$handshake" > "$presence"
printf "\\000\\000\\000\\000\\$(printf "%03o" "${#handshake}")\\000\\000\\000%s" "$handshake" >"$presence"
sleep 2
touch "$handshook"
fi
set_activity "$payload" > "$presence"
set_activity "$payload" >"$presence"
}
play() {
@@ -198,7 +198,7 @@ play() {
#get song's audio url
random_no=$(head /dev/urandom | tr -dc '0-4' | cut -c1)
andy_yt_ver="7.03.52"
andy_yt_ver="7.05.54"
extra_up=$((random_no > 1))
droid_agent="com.google.android.apps.youtube.music/$andy_yt_ver (Linux; U; Android 1$random_no) gzip"
json="{
@@ -243,7 +243,7 @@ play() {
get_song_lyrics "$id" &
#start the presence
pgrep -f "nc -U $discord_ipc" > /dev/null || setsid -f "$0" start_rich_presence
pgrep -f "nc -U $discord_ipc" >/dev/null || setsid -f "$0" start_rich_presence
#update the discord rich presence, requires client id
update_rich_presence "$title" "$id" "$duration" &
@@ -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/12$(head /dev/urandom | tr -dc '3-6' | cut -c1).0.0.0 Safari/537.36"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
#call this script by script-name "function_name" "query"
[ -z "$1" ] && help "$@"