#!/bin/sh
#https://jav.guru parser
#copy the video resource link,script will auto parser to play
#author:Wos
function logo()
{
echo -e "\033[96;40m"
base64 -d <<<"H4sIAAAAAAAAA61QMQoDMQzb7xXaegel+U2ngPoQP76S7UCGclOTkMiWLOwAIP6wDuDkBVLHhvTD
9M53QVQANL0KWk4bBWKAH0ztgYTR+0HGFqQgaRFCdKGSlpWRutI98ZbwrNp22GCo81g0MGkP2DFy
NAMlnxJMYcOVoBXNBV5suojQVENhy44wva3kf3xmyW8++wuIP4rRtgEAAA=="|gunzip
echo -e "\033[0m"
}
HTMP=/tmp/javguru.html
HTMP2=/tmp/javguru2.html
HTMP3=/tmp/javguru3.html
UA="User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
RF="Referer: https://jav.guru/"
PXY="--connect-timeout 5 --retry 3 -x http://127.0.0.1:7891"
PPXY="--http-proxy=http://127.0.0.1:7891"
while :;
do
clear
logo
echo "jav.guru parser"
echo "copy jav.guru resource link,it will auto parser hls link to play"
LINK=$(xclip -selection clipboard -o 2>/dev/null)
if [[ $LINK =~ ^https:\/\/jav\.guru\/ ]]; then
xclip -selection clipboard /dev/null
curl ${PXY} -H "${UA}" -H "${RF}" -s "${LINK}"|grep -oE 'iframe_url":".*'|awk -F\" '{print $3}' > ${HTMP}
echo /dev/null > ${HTMP2}
while IFS= read -r line
do
echo "$line"|base64 -d >> ${HTMP2}
echo "" >> ${HTMP2}
done < ${HTMP}
DR=$(cat ${HTMP2}|grep -oE 'dd=.*&'|awk -F\= '{print $2}'|awk -F\& '{print $1}'|rev)
LINK="https://jav.guru/searcho/?dr="${DR}
echo "LINK:"$LINK
curl ${PXY} -H "${RF}" -H "${UA}" -i -s ${LINK} > ${HTMP}
LINK2=$(cat ${HTMP}|grep location|awk '{print $2}')
RF="Referer: "${LINK2}
LINK3=$(echo ${LINK2} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo "LINK3:"${LINK3}
curl ${PXY} -H "${UA}" -s "${LINK3}" > ${HTMP3}
LINK4="https://streamtape.net/get_video?"$(cat ${HTMP3}|grep -E "'botlink'"|grep -oE "id=.*'"|awk -F\' '{print $1}')"&stream=1"
FN=$(cat ${HTMP3}|grep "og:title"|awk -F\" '{print $4}'|awk -F\. '{print $1}')
echo "movie name:"${FN}
echo "LINK4:"${LINK4}
mpv ${PPXY} --really-quiet --http-header-fields="Referer: ${LINK4}" "${LINK4}"
else
sleep 1
continue
fi
done