mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
implement optional quality selection with -q flag
by default the script searches for the best quality video with the -q flag, you will be prompted to choose betweeen 'best' and 'worst' quality
This commit is contained in:
parent
741b933b83
commit
41cfdb41d6
19
ani-cli
19
ani-cli
@ -141,14 +141,12 @@ get_links() {
|
|||||||
q
|
q
|
||||||
}
|
}
|
||||||
')
|
')
|
||||||
printf '%s' "$video_url"
|
|
||||||
|
|
||||||
# TODO: implement quality selection
|
tmp_url=$(printf '%s' "$video_url" | sed -n -E 's/(.*)\.([0-9]+\.[0-9]+)\.[0-9]+\.m3u8/\1.\2.m3u8/p')
|
||||||
# tmp_url=$(printf '%s' "$video_url" | sed -n -E 's/(.*)\.([0-9]+\.[0-9]+)\.[0-9]+\.m3u8/\1.\2.m3u8/p')
|
[ -z "$tmp_url" ] || video_url="$tmp_url"
|
||||||
# [ -z "$tmp_url" ] || video_url="$tmp_url"
|
video_quality=$(get_video_quality "$embedded_video_url" "$video_url")
|
||||||
# video_quality=$(get_video_quality "$embedded_video_url" "$video_url")
|
# Replace the video with highest quality video
|
||||||
# # Replace the video with highest quality video
|
printf '%s' "$video_url" | sed -n -E "s/(.*)\.m3u8/\1.$video_quality.m3u8/p"
|
||||||
# printf '%s' "$video_url" | sed -n -E "s/(.*)\.m3u8/\1.$video_quality.m3u8/p"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_ch() {
|
dep_ch() {
|
||||||
@ -551,7 +549,8 @@ download_dir="."
|
|||||||
is_playlist=0
|
is_playlist=0
|
||||||
playlist_remove=0
|
playlist_remove=0
|
||||||
playlist_add=0
|
playlist_add=0
|
||||||
while getopts 'hd:Hpa:P:sv' OPT; do
|
quality=best
|
||||||
|
while getopts 'hd:Hpa:P:svq:' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
h)
|
h)
|
||||||
help_text
|
help_text
|
||||||
@ -590,6 +589,10 @@ while getopts 'hd:Hpa:P:sv' OPT; do
|
|||||||
v)
|
v)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
;;
|
;;
|
||||||
|
q)
|
||||||
|
quality="$OPTARG"
|
||||||
|
log "passed in quality: $quality"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%s\n" "Invalid option"
|
printf "%s\n" "Invalid option"
|
||||||
exit 1
|
exit 1
|
||||||
|
79
aniwrapper
79
aniwrapper
@ -1,36 +1,39 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
set -Eeuo pipefail
|
||||||
|
|
||||||
CMD=/usr/bin/ani-cli
|
#############
|
||||||
|
# Globals #
|
||||||
|
#############
|
||||||
|
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
CMD="/usr/bin/ani-cli"
|
||||||
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
||||||
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
|
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
|
||||||
DEFAULT_PLAYLIST="$CFG_DIR/playlists/playlist.txt"
|
DEFAULT_PLAYLIST="$CFG_DIR/playlists/playlist.txt"
|
||||||
CFG_FILE="meh.rasi"
|
CFG_FILE="meh.rasi"
|
||||||
|
QUALITIES="1. best|2. worst"
|
||||||
|
QUALITY="best"
|
||||||
|
CHECK_QUALITY=0
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
|
|
||||||
while getopts 'vh' OPT; do
|
|
||||||
case "$OPT" in
|
|
||||||
h)
|
|
||||||
help_text
|
|
||||||
;;
|
|
||||||
v)
|
|
||||||
VERBOSE=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log "Invalid option"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
quit="6. Quit"
|
quit="6. Quit"
|
||||||
options="1. Stream|2. Download|3. Continue|4. Playlist|5. Sync History|$quit"
|
options="1. Stream|2. Download|3. Continue|4. Playlist|5. Sync History|$quit"
|
||||||
|
|
||||||
[ "$VERBOSE" -eq 1 ] && printf "%s\n" "CONFIG DIR: $CFG_DIR"
|
|
||||||
|
|
||||||
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' \
|
#############
|
||||||
-config "$CFG_DIR/$CFG_FILE" -l 6 -i -p "Aniwrapper")
|
# Functions #
|
||||||
|
#############
|
||||||
|
get_quality() {
|
||||||
|
selection=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
|
-l 1 -p "Choose video quality:" -sep '|' <<< "$QUALITIES")
|
||||||
|
QUALITY=$(awk '{print $2}' <<< "$selection")
|
||||||
|
log "selected quality: $QUALITY"
|
||||||
|
if [[ "$QUALITY" == 'best' || "$QUALITY" == 'worst' ]]; then
|
||||||
|
log "QUALITY: $QUALITY"
|
||||||
|
else
|
||||||
|
seppuku "Something went wrong getting the quality: $QUALITY... exiting"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
seppuku() {
|
seppuku() {
|
||||||
printf "%s\n" "$*"
|
printf "%s\n" "$*"
|
||||||
@ -43,10 +46,15 @@ quit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
|
if [[ "$CHECK_QUALITY" -eq 1 ]]; then
|
||||||
|
get_quality
|
||||||
|
else
|
||||||
|
log "CHECK_QUALITY disabled... using default: $QUALITY"
|
||||||
|
fi
|
||||||
if [[ "$VERBOSE" -eq 0 ]]; then
|
if [[ "$VERBOSE" -eq 0 ]]; then
|
||||||
"$CMD" "$*"
|
"$CMD" -q "$QUALITY" "$*"
|
||||||
else
|
else
|
||||||
"$CMD" -v "$*"
|
"$CMD" -q "$QUALITY" -v "$*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +64,33 @@ log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########
|
||||||
|
# Main #
|
||||||
|
########
|
||||||
|
while getopts 'vhq' OPT; do
|
||||||
|
case "$OPT" in
|
||||||
|
h)
|
||||||
|
help_text
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
VERBOSE=1
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
CHECK_QUALITY=1
|
||||||
|
log "Quality prompt enabled"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "Invalid option"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$VERBOSE" -eq 1 ] && printf "%s\n" "CONFIG DIR: $CFG_DIR"
|
||||||
|
|
||||||
|
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' \
|
||||||
|
-config "$CFG_DIR/$CFG_FILE" -l 6 -i -p "Aniwrapper")
|
||||||
|
|
||||||
[ "$choice" == "$quit" ] && quit
|
[ "$choice" == "$quit" ] && quit
|
||||||
|
|
||||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||||
|
Loading…
Reference in New Issue
Block a user