mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
add option to download current episode
This commit is contained in:
parent
4d704d4b32
commit
8882405c0e
101
ani-cli
101
ani-cli
@ -138,6 +138,54 @@ get_video_quality() {
|
|||||||
printf '%s' "$video_link"
|
printf '%s' "$video_link"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_video_quality() {
|
||||||
|
if ((IS_ROFI == 1)); then
|
||||||
|
qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
|
||||||
|
while IFS='|' read -ra quals; do
|
||||||
|
for q in "${quals[@]}"; do
|
||||||
|
if [[ "$(awk '{ print $NF }' <<< "$q")" == "$quality" ]]; then
|
||||||
|
cur_quality="$((${q:0:1} - 1))"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done <<< "$qualities"
|
||||||
|
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
||||||
|
-theme-str 'listview {columns: 1;} window {width: 25%;}' \
|
||||||
|
-i -l 6 -no-custom -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
|
||||||
|
-p "Choose quality:" -window-title 'aniwrapper' -selected-row "$cur_quality" <<< "$qualities")
|
||||||
|
quality=$(awk '{ print $2 }' <<< "$choice")
|
||||||
|
else
|
||||||
|
qualities="best|1080p|720p|480p|360p|worst"
|
||||||
|
prompt "Choose quality [$qualities]"
|
||||||
|
read -r quality
|
||||||
|
while [[ ! "$quality" =~ ($qualities) ]]; do
|
||||||
|
lg "$quality not a valid quality"
|
||||||
|
prompt "Choose quality [$qualities]"
|
||||||
|
read -r quality
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
[ -z "$quality" ] && die "No quality selected"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_dl_dir() {
|
||||||
|
if ((IS_ROFI == 1)); then
|
||||||
|
download_dir=$(
|
||||||
|
rofi -dpi "$DPI" -dmenu -config "$ROFI_CFG" \
|
||||||
|
-theme-str 'listview {columns: 1;} window {width: 45%;}' \
|
||||||
|
-mesg "$(generate_span "Enter the path to the download directory, or leave blank to go with the default: $HOME/Videos/sauce/")" \
|
||||||
|
-l 1 -p "Enter download dir:" -window-title 'aniwrapper'
|
||||||
|
)
|
||||||
|
else
|
||||||
|
prompt "Enter download directory"
|
||||||
|
read -r download_dir
|
||||||
|
fi
|
||||||
|
lg "Download dir: $download_dir"
|
||||||
|
[ -z "$download_dir" ] && download_dir="$HOME/Videos/sauce/"
|
||||||
|
if [ ! -d "$download_dir" ]; then
|
||||||
|
mkdir -p "$download_dir" || die "Error creating directory: $download_dir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
dep_ch() {
|
dep_ch() {
|
||||||
for dep; do
|
for dep; do
|
||||||
if ! command -v "$dep" > /dev/null; then
|
if ! command -v "$dep" > /dev/null; then
|
||||||
@ -867,18 +915,14 @@ main() {
|
|||||||
choice=''
|
choice=''
|
||||||
while :; do
|
while :; do
|
||||||
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
||||||
if ((episode != LAST_EP_NUMBER)); then
|
((episode != LAST_EP_NUMBER)) && menu_line_alternate "next episode" "n"
|
||||||
menu_line_alternate "next episode" "n"
|
((episode != FIRST_EP_NUMBER)) && menu_line_alternate "previous episode" "p"
|
||||||
fi
|
((FIRST_EP_NUMBER != LAST_EP_NUMBER)) && menu_line_alternate "select episode" "s"
|
||||||
if ((episode != FIRST_EP_NUMBER)); then
|
|
||||||
menu_line_alternate "previous episode" "p"
|
|
||||||
fi
|
|
||||||
if ((FIRST_EP_NUMBER != LAST_EP_NUMBER)); then
|
|
||||||
menu_line_alternate "select episode" "s"
|
|
||||||
fi
|
|
||||||
menu_line_alternate "replay current episode" "r"
|
menu_line_alternate "replay current episode" "r"
|
||||||
menu_line_alternate "search for another anime" "a"
|
menu_line_alternate "search for another anime" "a"
|
||||||
menu_line_alternate "select quality (current: $quality)" "Q"
|
menu_line_alternate "download current episode" "d"
|
||||||
|
menu_line_alternate "download current episode (with quality selection)" "D"
|
||||||
|
menu_line_alternate "select video quality (current: $quality)" "Q"
|
||||||
menu_line_strong "exit" "q"
|
menu_line_strong "exit" "q"
|
||||||
prompt "Enter choice"
|
prompt "Enter choice"
|
||||||
read -r choice
|
read -r choice
|
||||||
@ -904,34 +948,21 @@ main() {
|
|||||||
lg "NEW EPISODE: $selection_id - $episode"
|
lg "NEW EPISODE: $selection_id - $episode"
|
||||||
;;
|
;;
|
||||||
Q)
|
Q)
|
||||||
if ((IS_ROFI == 1)); then
|
set_video_quality
|
||||||
qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
|
|
||||||
while IFS='|' read -ra quals; do
|
|
||||||
for q in "${quals[@]}"; do
|
|
||||||
if [[ "$(awk '{ print $NF }' <<< "$q")" == "$quality" ]]; then
|
|
||||||
cur_quality="$((${q:0:1} - 1))"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done <<< "$qualities"
|
|
||||||
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
|
||||||
-theme-str 'listview {columns: 1;} window {width: 25%;}' \
|
|
||||||
-i -l 6 -no-custom -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
|
|
||||||
-p "Choose quality:" -window-title 'aniwrapper' -selected-row "$cur_quality" <<< "$qualities")
|
|
||||||
quality=$(awk '{ print $2 }' <<< "$choice")
|
|
||||||
else
|
|
||||||
qualities="best|1080p|720p|480p|360p|worst"
|
|
||||||
prompt "Choose quality [$qualities]"
|
|
||||||
read -r quality
|
|
||||||
while [[ ! "$quality" =~ ($qualities) ]]; do
|
|
||||||
lg "$quality not a valid quality"
|
|
||||||
prompt "Choose quality [$qualities]"
|
|
||||||
read -r quality
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
episode=$((episode))
|
episode=$((episode))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
d)
|
||||||
|
get_dl_dir
|
||||||
|
is_download=1
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
D)
|
||||||
|
get_dl_dir
|
||||||
|
set_video_quality
|
||||||
|
is_download=1
|
||||||
|
break
|
||||||
|
;;
|
||||||
q)
|
q)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user