mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07: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
|
||||||
|
31
ani-cli
31
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)
|
|
||||||
|
while getopts 'hd' OPT; do
|
||||||
|
case $OPT in
|
||||||
|
h)
|
||||||
help_text
|
help_text
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
||||||
|
|
||||||
|
if [ $is_download -eq 0 ]; then
|
||||||
setsid -f mpv "$video_url" >/dev/null 2>&1
|
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