revert changes

This commit is contained in:
ksyasuda 2022-06-12 18:36:30 -07:00
parent 80682a26db
commit 822e40074c

View File

@ -60,7 +60,7 @@ Options:
} }
lg() { lg() {
if ((VERBOSE)); then if ((VERBOSE == 1)); then
inf "$*" inf "$*"
fi fi
} }
@ -86,26 +86,26 @@ quit() {
} }
run() { run() {
if ((!IS_PLAY_FROM_FILE && !IS_SYNC && GET_QUALITY)); then if ((IS_PLAY_FROM_FILE == 0 && IS_SYNC == 0 && GET_QUALITY == 1)); then
get_quality get_quality
fi fi
if ((IS_AUTOPLAY)); then if ((IS_AUTOPLAY)); then
CMD="$CMD -a" CMD="$CMD -a"
fi fi
if ((SILENT)); then if ((SILENT == 1)); then
if ((!IS_CUSTOM_THEME)); then if ((IS_CUSTOM_THEME == 0)); then
$CMD -D"$DPI" -Sq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -Sq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else else
$CMD -D"$DPI" -Sq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -Sq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
fi fi
elif ((VERBOSE)); then elif ((VERBOSE == 1)); then
if ((!IS_CUSTOM_THEME)); then if ((IS_CUSTOM_THEME == 0)); then
$CMD -D"$DPI" -vq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -vq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else else
$CMD -D"$DPI" -vq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -vq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
fi fi
else else
if ((!IS_CUSTOM_THEME)); then if ((IS_CUSTOM_THEME == 0)); then
$CMD -D"$DPI" -q "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -q "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else else
$CMD -D"$DPI" -q "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@" $CMD -D"$DPI" -q "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
@ -114,7 +114,7 @@ run() {
} }
get_quality() { get_quality() {
if ((IS_ROFI)); then if ((IS_ROFI == 1)); then
selection=$(rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \ selection=$(rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
-l 6 -selected-row 0 -a 0 -window-title 'aniwrapper' \ -l 6 -selected-row 0 -a 0 -window-title 'aniwrapper' \
-theme-str 'listview {columns: 1;} window {width: 25%;}' \ -theme-str 'listview {columns: 1;} window {width: 25%;}' \
@ -247,7 +247,7 @@ parse_args() {
get_player() { get_player() {
msg1="Choose from the supported players, or supply your own player command (full functionality not guaranteed)" msg1="Choose from the supported players, or supply your own player command (full functionality not guaranteed)"
msg2="if using an unsupported player, it must be able to play URLs for streaming from the internet" msg2="if using an unsupported player, it must be able to play URLs for streaming from the internet"
if ((IS_ROFI)); then if ((IS_ROFI == 1)); then
PLAYER_FN=$( PLAYER_FN=$(
awk '{print $NF}' < <(rofi -dmenu -config "$CFG_FILE" -DPI "$DPI" \ awk '{print $NF}' < <(rofi -dmenu -config "$CFG_FILE" -DPI "$DPI" \
-l 4 -theme-str 'listview {columns: 1;} window {width: 40%;}' \ -l 4 -theme-str 'listview {columns: 1;} window {width: 40%;}' \
@ -270,59 +270,48 @@ get_player() {
fi fi
} }
# Check passed in flags and set cli arguments
check_flags() { check_flags() {
if ((VERBOSE && SILENT)); then # Check if command-line flag is set
if ((VERBOSE == 1 && SILENT == 1)); then
die "verbose and silent options cannot be used together" die "verbose and silent options cannot be used together"
fi fi
if ((IS_DOWNLOAD && IS_AUTOPLAY)); then if ((IS_DOWNLOAD == 1 && IS_AUTOPLAY == 1)); then
die "autoplay and download options cannot be used together" die "autoplay and download options cannot be used together"
fi fi
if ((IS_DOWNLOAD && IS_PLAY_FROM_FILE)); then if ((IS_DOWNLOAD == 0 && IS_ALTERNATE_PLAYER == 1)); then
die "download and play from file options cannot be used together"
fi
if ((!IS_DOWNLOAD && IS_ALTERNATE_PLAYER)); then
get_player get_player
lg "SELECTED PLAYER FN -> $PLAYER_FN" lg "SELECTED PLAYER FN -> $PLAYER_FN"
fi fi
args=() if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then
if ((IS_AUTOPLAY)); then if ((IS_RESUME == 1)); then
args+=(-a) run -cr "$@"
else
run -c "$@"
fi fi
if ((!IS_ROFI)); then exit $?
args+=(-c) elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then
prompt "Enter download directory" prompt "Enter download directory"
read -r dl_dir read -r dl_dir
lg "Download dir: $dl_dir" lg "Download dir: $dl_dir"
if [ ! -d "$dl_dir" ]; then if [ ! -d "$dl_dir" ]; then
mkdir -p "$dl_dir" || die "Error creating directory: $dl_dir" mkdir -p "$dl_dir" || die "Error creating directory: $dl_dir"
fi fi
args+=(-d "$dl_dir") if ((IS_RESUME == 1)); then
run "-crd" "$dl_dir" "$@"
else
run "-cd $dl_dir" "$@"
fi fi
if ((IS_DOWNLOAD)); then
args+=(-d)
fi
if ((IS_PLAY_FROM_FILE)); then
args+=(-f "$play_path")
fi
if ((IS_ALTERNATE_PLAYER)); then
args+=(-p "$PLAYER_FN")
fi
if ((IS_QUALITY)); then
args+=(-q)
fi
if ((IS_RESUME)); then
args+=(-r)
fi
if ((IS_CUSTOM_THEME)); then
args+=(-T "$CFG_FILE")
elif ((!IS_CUSTOM_THEME)); then
args+=(-t "$theme")
fi
lg "ARGS: ${args[*]}"
run "${args[@]}" "$@"
exit $? exit $?
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 1)); then
run "-f$play_path" -T "$CFG_FILE" "$@"
exit $?
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then
run "-f$play_path" -t "$theme" "$@"
exit $?
elif ((IS_RESUME == 1)); then
run -r "$@"
exit $?
fi
} }
get_dl_dir() { get_dl_dir() {
@ -434,9 +423,9 @@ parse_args "$@"
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
check_flags "$*" check_flags "$*"
if ((!IS_DOWNLOAD)); then if ((IS_DOWNLOAD == 0)); then
run "$*" run "$*"
elif ((IS_DOWNLOAD)); then elif ((IS_DOWNLOAD == 1)); then
get_dl_dir && run -d "$dl_dir" "$*" get_dl_dir && run -d "$dl_dir" "$*"
fi fi
else else