Compare commits

...

2 Commits

Author SHA1 Message Date
ksyasuda
af7dee7d85 update cli flag parsing and cleanup code 2022-06-12 18:52:26 -07:00
ksyasuda
822e40074c revert changes 2022-06-12 18:36:30 -07:00

View File

@ -89,28 +89,7 @@ run() {
if ((!IS_PLAY_FROM_FILE && !IS_SYNC && GET_QUALITY)); then
get_quality
fi
if ((IS_AUTOPLAY)); then
CMD="$CMD -a"
fi
if ((SILENT)); then
if ((!IS_CUSTOM_THEME)); then
$CMD -D"$DPI" -Sq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else
$CMD -D"$DPI" -Sq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
fi
elif ((VERBOSE)); then
if ((!IS_CUSTOM_THEME)); then
$CMD -D"$DPI" -vq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else
$CMD -D"$DPI" -vq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
fi
else
if ((!IS_CUSTOM_THEME)); then
$CMD -D"$DPI" -q "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
else
$CMD -D"$DPI" -q "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
fi
fi
$CMD -D"$DPI" "$@"
}
get_quality() {
@ -308,21 +287,26 @@ check_flags() {
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_SILENT)); then
args+=(-S)
fi
if ((IS_CUSTOM_THEME)); then
args+=(-T "$CFG_FILE")
elif ((!IS_CUSTOM_THEME)); then
args+=(-t "$theme")
fi
if ((IS_VERBOSE)); then
args+=(-v)
fi
lg "ARGS: ${args[*]}"
run "${args[@]}" "$@"
exit $?
if ((IS_DOWNLOAD || !IS_ROFI || IS_RESUME || IS_PLAY_FROM_FILE)); then
run "${args[@]}" "$@"
exit $?
fi
}
get_dl_dir() {
@ -340,8 +324,8 @@ get_dl_dir() {
}
main() {
((SILENT != 1)) && lg "CONFIG DIR: $CFG_DIR"
((SILENT != 1)) && lg "ROFI CFG: $CFG_FILE"
((!SILENT)) && lg "CONFIG DIR: $CFG_DIR"
((!SILENT)) && lg "ROFI CFG: $CFG_FILE"
choice=$(echo "${options[@]}" | rofi -dpi "$DPI" -dmenu -no-custom -sep '|' \
-theme-str 'listview {columns: 2;} window {width: 45%;}' \
-config "$CFG_FILE" -l 4 -i -p "Aniwrapper" -window-title 'aniwrapper')
@ -353,19 +337,19 @@ main() {
case "$selection" in
1.)
lg "Streaming mode"
run
run "${args[@]}"
;;
2.)
lg "Download anime"
get_dl_dir && run -d "$dl_dir"
get_dl_dir && run "${args[@]}" -d "$dl_dir"
;;
3.)
lg "Continue watching"
run -H
run -H "${args[@]}"
;;
4.)
lg "Showing recently updated anime"
run -R
run -R "${args[@]}"
;;
5.)
lg "Play from file selected"
@ -383,9 +367,9 @@ main() {
lg "Play dir: $play_dir"
if [ -z "$play_dir" ]; then
mkdir -p "$DEFAULT_DOWNLOAD" || die "error creating default download directory"
run -f"$DEFAULT_DOWNLOAD"
run -f"$DEFAULT_DOWNLOAD" "${args[@]}"
else
run -f"$play_dir"
run -f"$play_dir" "${args[@]}"
fi
exit $?
;;