fix ani-cli script

This commit is contained in:
CoolnsX
2022-01-07 17:16:23 +05:30
parent 199646890f
commit 5b1d3d4af8

25
ani-cli
View File

@@ -21,6 +21,7 @@ help_text () {
USAGE: $prog <query> USAGE: $prog <query>
-h show this help text -h show this help text
-d download episode -d download episode
-c cast episode
EOF EOF
} }
@@ -65,19 +66,15 @@ get_embedded_video_link() {
ep_no=$2 ep_no=$2
curl -s "https://$site/$anime_id-episode-$ep_no" | curl -s "https://$site/$anime_id-episode-$ep_no" |
sed -n -E 's/^[[:space:]]*<li class="dowloads"><a href="([^"]*)".*/\1/p' sed -n -E 's/.*rel="13" data-video="([^"]*)".*/\1/p' | cut -d/ -f5
} }
get_links () { get_links () {
dpage_link="$1" dpage_link="$1"
sb_url=$(curl -s "$dpage_link" | h=$(curl -s "https://sbplay2.com/d/$dpage_link" | sed -n -E 's/.*a href="#" onclick="download_video([^"]*)".*/\1/p' | head -1 | cut -d\' -f6)
sed -n -E 's/^[[:space:]]*href="([^"]*)".*/\1/p' | grep -oE ".*sbplay.*")
link=$(curl -s "$sb_url" | sed -n -E 's/.*a href="#" onclick="download_video([^"]*)".*/\1/p')
i=$(printf "$link" | cut -d\' -f2 | head -1) lol=$(curl -s "https://sbplay2.com/dl?op=download_orig&id=$dpage_link&mode=h&hash=$h" | sed -n -E 's/<a href="([^"]*.mp4)".*/\1/p')
h=$(printf "$link" | cut -d\' -f6 | head -1) [ -z "$lol" ] && lol=$(curl -s "https://sbplay2.com/dl?op=download_orig&id=$dpage_link&mode=n&hash=$h" | sed -n -E 's/<a href="([^"]*.mp4)".*/\1/p')
lol=$(curl -s "https://sbplay2.com/dl?op=download_orig&id=$i&mode=h&hash=$h" | sed -n -E 's/<a href="([^"]*.mp4)".*/\1/p')
[ -z "$lol" ] && lol=$(curl -s "https://sbplay2.com/dl?op=download_orig&id=$i&mode=n&hash=$h" | sed -n -E 's/<a href="([^"]*.mp4)".*/\1/p')
printf "$lol" printf "$lol"
} }
@@ -182,7 +179,11 @@ open_episode () {
echo "$video_url" echo "$video_url"
if [ $is_download -eq 0 ]; then if [ $is_download -eq 0 ]; then
setsid -f $player_fn --http-header-fields="Referer: https://sbplay2.com" "$video_url" > /dev/null 2>&1 if [ $is_cast -eq 0 ]; then
setsid -f $player_fn --http-header-fields="Referer: https://sbplay2.com" "$video_url" > /dev/null 2>&1
else
catt cast "$video_url"
fi
else else
printf "Downloading episode $episode ...\n" printf "Downloading episode $episode ...\n"
# add 0 padding to the episode name # add 0 padding to the episode name
@@ -206,7 +207,8 @@ dep_ch "$player_fn" "curl" "sed" "grep"
# option parsing # option parsing
is_download=0 is_download=0
while getopts 'hd' OPT; do is_cast=0
while getopts 'hdc' OPT; do
case $OPT in case $OPT in
h) h)
help_text help_text
@@ -215,6 +217,9 @@ while getopts 'hd' OPT; do
d) d)
is_download=1 is_download=1
;; ;;
c)
is_cast=1
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))