mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
feat: download feature
This commit is contained in:
parent
4a77126a7c
commit
bf903f746e
@ -7,8 +7,12 @@ This tool scrapes the site [gogoanime](https://gogoanime.vc).
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
# watch anime
|
||||||
ani-cli <query>
|
ani-cli <query>
|
||||||
|
|
||||||
|
# download anime
|
||||||
|
ani-cli -d <query>
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* curl
|
* curl
|
||||||
|
39
ani-cli
39
ani-cli
@ -12,11 +12,14 @@ c_magenta="\033[1;35m"
|
|||||||
c_cyan="\033[1;36m"
|
c_cyan="\033[1;36m"
|
||||||
c_reset="\033[0m"
|
c_reset="\033[0m"
|
||||||
|
|
||||||
|
|
||||||
help_text () {
|
help_text () {
|
||||||
while IFS= read line; do
|
while IFS= read line; do
|
||||||
printf "%s\n" "$line"
|
printf "%s\n" "$line"
|
||||||
done <<-EOF
|
done <<-EOF
|
||||||
USAGE: $prog <query>
|
USAGE: $prog <query>
|
||||||
|
-h show this help text
|
||||||
|
-d download episode
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +82,21 @@ get_links () {
|
|||||||
## Anime selection ##
|
## Anime selection ##
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
case $1 in
|
is_download=0
|
||||||
-h|--help)
|
|
||||||
help_text
|
while getopts 'hd' OPT; do
|
||||||
exit 0
|
case $OPT in
|
||||||
;;
|
h)
|
||||||
esac
|
help_text
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
is_download=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
[ -z "$*" ] && { help_text ; die "Search query not provided"; }
|
[ -z "$*" ] && { help_text ; die "Search query not provided"; }
|
||||||
|
|
||||||
@ -171,7 +183,17 @@ while :; do
|
|||||||
');;
|
');;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
setsid -f mpv "$video_url" >/dev/null 2>&1
|
if [ $is_download -eq 0 ]; then
|
||||||
|
setsid -f mpv "$video_url" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
printf "Downloading episode $ep_choice ...\n"
|
||||||
|
printf "%s\n" "$video_url"
|
||||||
|
{
|
||||||
|
curl -L -# "$video_url" -o "${anime_id}-${ep_choice}.mp4" &&
|
||||||
|
printf "\n${c_green}Downloaded episode: %s${c_reset}\n" "$ep_choice" ||
|
||||||
|
printf "\n${c_red}Download failed episode: %s${c_reset}\n" "$ep_choice"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
printf "\n${c_green}Currently playing %s episode ${c_cyan}%d/%d\n" "$selection_id" $ep_choice $last_ep_number
|
printf "\n${c_green}Currently playing %s episode ${c_cyan}%d/%d\n" "$selection_id" $ep_choice $last_ep_number
|
||||||
printf "$c_blue[${c_cyan}%s$c_blue] $c_yellow%s$c_reset\n" "n" "next episode"
|
printf "$c_blue[${c_cyan}%s$c_blue] $c_yellow%s$c_reset\n" "n" "next episode"
|
||||||
@ -188,10 +210,9 @@ while :; do
|
|||||||
ep_choice=$((ep_choice-1))
|
ep_choice=$((ep_choice-1))
|
||||||
;;
|
;;
|
||||||
q)
|
q)
|
||||||
exit 0;;
|
break;;
|
||||||
*)
|
*)
|
||||||
die "invalid choice"
|
die "invalid choice"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user