added user-agent in scripts

This commit is contained in:
CoolnsX
2022-02-23 18:28:51 +05:30
parent 0e9dfc1577
commit b12d3472ce
3 changed files with 17 additions and 34 deletions

34
ani-cli
View File

@@ -5,6 +5,7 @@
player_fn="mpv"
prog="ani-cli"
site="gogoanime.film"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
c_red="\033[1;31m"
c_green="\033[1;32m"
@@ -21,7 +22,6 @@ help_text () {
USAGE: $prog <query>
-h show this help text
-d download episode
-c cast anime
EOF
}
@@ -37,23 +37,19 @@ err () {
search_anime () {
# get anime name along with its id
search=$1
curl -s "https://$site//search.html?keyword=$search" |
sed -n -E '
s_^[[:space:]]*<a href="/category/([^"]*)" title="([^"]*)".*_\1_p
'
curl -s "https://$site//search.html?keyword=$search" | sed -n -E '
s_^[[:space:]]*<a href="/category/([^"]*)" title="([^"]*)".*_\1_p'
}
search_eps () {
# get available episodes for anime_id
anime_id=$1
curl -s "https://$site/category/$anime_id" |
sed -n -E '
curl -s "https://$site/category/$anime_id" | sed -n -E '
/^[[:space:]]*<a href="#" class="active" ep_start/{
s/.* '\''([0-9]*)'\'' ep_end = '\''([0-9]*)'\''.*/\2/p
q
}
'
}'
}
embade_link() {
@@ -68,17 +64,11 @@ embade_link() {
decrypt_link() {
ajax_url='https://gogoplay.io/encrypt-ajax.php'
#get the id from the url
video_id=$(printf "$1" | cut -d\? -f2 | cut -d\& -f1 | sed 's/id=//g')
#construct ajax parameters
secret_key='3235373436353338353932393338333936373634363632383739383333323838'
iv='34323036393133333738303038313335'
ajax=$(printf "$video_id" | openssl enc -aes256 -K "$secret_key" -iv "$iv" -a)
#send the request to the ajax url
curl -s -H 'x-requested-with:XMLHttpRequest' "$ajax_url" -d "id=$ajax" -d "time=69420691337800813569" | jq -r '.source[].file' | head -4 | tail -1
curl -s -H "X-Requested-With:XMLHttpRequest" -H "User-Agent:$agent" -H "Referer:$1" "$ajax_url" -d "id=$ajax" -d "time=69420691337800813569" | jq -r '.source[].file' | head -4 | tail -1
}
# get query
@@ -164,18 +154,14 @@ open_episode () {
printf "%s\n" "$video_url"
if [ $is_download -eq 0 ]; then
if [ $is_cast -eq 0 ]; then
([ -z $ep_choice_end ] &&
setsid -f $player_fn --referrer="$embedded_url" "$video_url" >/dev/null 2>&1 || $player_fn --referrer="$embedded_url" "$video_url" >/dev/null 2>&1)
else
catt cast "$video_url"
fi
setsid -f $player_fn --http-header-fields="User-Agent:$agent" --referrer="$embedded_url" "$video_url" >/dev/null 2>&1 || $player_fn --referrer="$embedded_url" "$video_url" >/dev/null 2>&1)
else
printf "Downloading episode $episode ...\n"
# add 0 padding to the episode name
episode=$(printf "%03d" $episode)
{
aria2c -x 16 -s 16 --referer "$embedded_url" "$video_url" --dir=MOVIES -o "${anime_id}-${episode}.mp4" &&
aria2c -x 16 -s 16 -U "$agent" --referer "$embedded_url" "$video_url" --dir=MOVIES -o "${anime_id}-${episode}.mp4" &&
printf "${c_green}Downloaded episode: %s${c_reset}\n" "$episode" ||
printf "${c_red}Download failed episode: %s${c_reset}\n" "$episode"
}
@@ -191,7 +177,6 @@ trap "printf '$c_reset';exit 1" INT HUP
# option parsing
is_download=0
is_cast=0
while getopts 'hdc' OPT; do
case $OPT in
h)
@@ -201,9 +186,6 @@ while getopts 'hdc' OPT; do
d)
is_download=1
;;
c)
is_cast=1
;;
esac
done
shift $((OPTIND - 1))

View File

@@ -1,17 +1,18 @@
#!/bin/sh
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
decrypt_link() {
ajax_url='https://gogoplay.io/encrypt-ajax.php'
video_id=$(printf "$1" | cut -d\? -f2 | cut -d\& -f1 | sed 's/id=//g')
secret_key='3235373436353338353932393338333936373634363632383739383333323838'
iv='34323036393133333738303038313335'
ajax=$(printf "$video_id" | openssl enc -aes256 -K "$secret_key" -iv "$iv" -a)
curl -s -H 'x-requested-with:XMLHttpRequest' "$ajax_url" -d "id=$ajax" -d "time=69420691337800813569" | jq -r '.source[].file' | head -4 | tail -1
curl -s -H "X-Requested-With:XMLHttpRequest" -H "User-Agent:$agent" -H "Referer:https:$1" "$ajax_url" -d "id=$ajax" -d "time=69420691337800813569" | jq -r '.source[].file' | head -4 | tail -1
}
url=$(curl -s "https://gogoanime.film" | sed -nE 's/.*"name".*href="\/([^"]*)".*/\1/p' | dmenu -p "Select anime:")
url=$(curl -s -A "$agent" "https://gogoanime.film" | sed -nE 's/.*"name".*href="\/([^"]*)".*/\1/p' | dmenu -p "Select anime:")
[ -z "$url" ] && notify-send -u critical "Err.. no anime selected" && exit 0
refr=$(curl -s "https://gogoanime.film/$url" | sed -n -E 's/^[[:space:]]*<a href="#" rel="100" data-video="([^"]*)".*/\1/p')
refr=$(curl -s -A "$agent" "https://gogoanime.film/$url" | sed -n -E 's/^[[:space:]]*<a href="#" rel="100" data-video="([^"]*)".*/\1/p')
video=$(decrypt_link "$refr")
notify-send "Downloading $url"
st -e aria2c --summary-interval=0 -x 16 -s 16 --referer="https:$refr" "$video" -o "$url.mp4" --download-result=hide && notify-send "Downloaded $url"
st -e aria2c --summary-interval=0 -x 16 -s 16 -U "$agent" --referer="https:$refr" "$video" --dir=MOVIES -o "$url.mp4" --download-result=hide && notify-send "Downloaded $url"

4
nsfw
View File

@@ -3,7 +3,7 @@
[ -z "$*" ] && printf "enter(paste) number or link:" && read -r num || num=$*
num=$(printf "$num" | cut -d\/ -f5)
dir="$HOME/.cache/$num"
mkdir -pv $dir
mkdir -p $dir
trap "rm -rf $dir;exit 0" INT HUP
pg=$(curl -s "https://nhentai.net/g/$num/1/" | sed -nE 's/.*pages">(.*)<\/span><.*/\1/p')
echo "pages : $pg"
@@ -19,4 +19,4 @@ echo "waiting 5 sec for pages to download completely"
sleep 5
echo "concatenating pages to pdf"
convert "$dir/*" "$num.pdf" && printf "saved pdf as $num.pdf\nopening pdf...enjoy 😏😏" && setsid -f xdg-open "$num.pdf"
rm -rvf $dir
rm -rf $dir