add 480p quality

This commit is contained in:
ksyasuda 2022-02-09 20:22:54 -08:00
parent 3647be366f
commit 3b5511cfb4
2 changed files with 47 additions and 11 deletions

13
ani-cli
View File

@ -917,6 +917,7 @@ main() {
;;
Q)
if ((IS_ROFI == 1)); then
qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
case "$quality" in
best)
cur_quality=0
@ -927,20 +928,20 @@ main() {
720p)
cur_quality=2
;;
360p)
480p)
cur_quality=3
;;
worst)
360p)
cur_quality=4
;;
*)
cur_quality=0
worst)
cur_quality=5
;;
esac
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
-theme-str 'listview {columns: 1;} window {width: 20%;}' \
-i -l 5 -only-match -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
-p "Choose quality:" <<< "1. best|2. 1080p|3. 720p|4. 360p|5. worst")
-i -l 6 -only-match -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
-p "Choose quality:" <<< "$qualities")
quality=$(awk '{ print $2 }' <<< "$choice")
else
qualities="best|1080p|720p|480p|360p|worst"

View File

@ -10,8 +10,8 @@ CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
CFG_FILE="$CFG_DIR/themes/aniwrapper.rasi"
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
ROFI_THEME="aniwrapper.rasi"
THEMES="aniwrapper (default)|dracula|doomone|fancy|material|nord|nord2|onedark"
QUALITIES="1. best|2. 1080p|3. 720p|4. 360p|5. worst"
THEMES="aniwrapper|dracula|doomone|fancy|material|nord|nord2|onedark"
QUALITIES="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
SUPPORTED_PLAYERS="mpv|mplayer|vlc"
QUALITY=best
PLAYER_FN=mpv
@ -54,7 +54,7 @@ Options:
-Q <query> query the history database
-v verbose output
-S silent mode (suppress output to stdout) [cannot be used with -v]
-t <aniwrapper (default)|dracula|doomone|fancy|flamingo|material|onedark> change rofi theme
-t <aniwrapper (default)|dracula|doomone|fancy|material|nord|nord2|onedark> change rofi theme
-T <config_path> specify custom rofi theme
"
}
@ -113,7 +113,7 @@ run() {
get_quality() {
if ((IS_ROFI == 1)); then
selection=$(rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
-l 5 -selected-row 0 -a 0 \
-l 6 -selected-row 0 -a 0 \
-theme-str 'listview {columns: 1;} window {width: 20%;}' \
-p "Choose video quality:" \
-sep '|' -only-match <<< "$QUALITIES")
@ -131,6 +131,40 @@ get_quality() {
lg "selected quality: $QUALITY"
}
# return the index in $THEMES of $ROFI_THEME
get_theme_idx() {
case "$ROFI_THEME" in
aniwrapper.rasi)
theme_idx=0
;;
aniwrapper-dracula.rasi)
theme_idx=1
;;
aniwrapper-doomone.rasi)
theme_idx=2
;;
aniwrapper-fancy.rasi)
theme_idx=3
;;
aniwrapper-material.rasi)
theme_idx=4
;;
aniwrapper-nord.rasi)
theme_idx=5
;;
aniwrapper-nord2.rasi)
theme_idx=6
;;
aniwrapper-onedark.rasi)
theme_idx=7
;;
*)
exit 1
;;
esac
printf "%s" "$theme_idx"
}
# generates a span mesg for rofi given
# input: message: str
generate_span() {
@ -395,7 +429,8 @@ main() {
choice=$(rofi -dmenu -config "$CFG_FILE" -dpi "$DPI" \
-theme-str 'listview {columns: 1;} window {width: 45%;}' \
-only-match -l 4 -i -p "Choose theme: " -sep '|' \
-theme-str 'listview { columns: 2; }' <<< "$THEMES")
-theme-str 'listview { columns: 2; }' \
-a "$(get_theme_idx)" <<< "$THEMES")
theme=$(awk '{ print $1 }' <<< "$choice")
set_theme "$theme"
main