mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
add menu and option for selecting provider to scrape (#14)
This commit is contained in:
parent
df82425eae
commit
2bab68a887
6
ani-cli
6
ani-cli
@ -446,7 +446,7 @@ parse_args() {
|
||||
is_download=0
|
||||
is_resume=0
|
||||
is_autoplay=0
|
||||
while getopts 'ad:Hsvq:cf:t:T:CQ:D:Sp:rR' OPT; do
|
||||
while getopts 'ad:Hsvq:cf:t:T:CQ:D:Sp:P:rR' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
is_autoplay=1
|
||||
@ -531,6 +531,10 @@ parse_args() {
|
||||
die "ERROR: $PLAYER_FN does not exist"
|
||||
fi
|
||||
;;
|
||||
P)
|
||||
select_provider="$OPTARG"
|
||||
((select_provider < 1 || select_provider > 7)) && die "Invalid provider: $select_provider"
|
||||
;;
|
||||
*)
|
||||
inf "Invalid option"
|
||||
exit 1
|
||||
|
44
aniwrapper
44
aniwrapper
@ -22,6 +22,7 @@ IS_ROFI=1
|
||||
IS_SYNC=0
|
||||
IS_ALTERNATE_PLAYER=0
|
||||
IS_VERBOSE=0
|
||||
SELECT_PROVIDER=0
|
||||
SILENT=0
|
||||
|
||||
quit="8. Quit"
|
||||
@ -46,6 +47,7 @@ Options:
|
||||
-f <path_to_directory> (no trailing slash) specify starting directory for play for file mode
|
||||
-h show this help text
|
||||
-p enable player selection menu
|
||||
-P select provider to scrape first
|
||||
-q enable quality selection
|
||||
-Q <query> query the history database
|
||||
-r start script in episode selection using the most recently watched anime
|
||||
@ -155,7 +157,7 @@ set_theme() {
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while getopts 'acCdD:f:hpqQ:rSt:T:v' OPT; do
|
||||
while getopts 'acCdD:f:hpPqQ:rSt:T:v' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
IS_AUTOPLAY=1
|
||||
@ -189,6 +191,9 @@ parse_args() {
|
||||
p)
|
||||
IS_ALTERNATE_PLAYER=1
|
||||
;;
|
||||
P)
|
||||
SELECT_PROVIDER=1
|
||||
;;
|
||||
q)
|
||||
GET_QUALITY=1
|
||||
lg "Quality prompt enabled"
|
||||
@ -252,6 +257,37 @@ get_player() {
|
||||
fi
|
||||
}
|
||||
|
||||
# prompts the user to select a provider and returns the provider name and index
|
||||
get_provider() {
|
||||
providers="1. Mp4upload|2. Doodstream|3. Streamlare|4. Okru|5. Xstreamcdn|6. Animixplay|7. Gogoanime"
|
||||
if ((IS_ROFI)); then
|
||||
selection="$(rofi -dmenu -config "$CFG_FILE" -DPI "$DPI" \
|
||||
-i -l 7 -theme-str 'listview {columns: 1;} window {width: 45%;}' \
|
||||
-p "Select provider:" -window-title 'aniwrapper' \
|
||||
-a 0 -sep '|' <<< "$providers")"
|
||||
[ -z "$selection" ] && selection=1
|
||||
provider_idx="${selection:0:1}"
|
||||
else
|
||||
printf "%s%s\n" "Select provider:" "[$providers]"
|
||||
prompt "Enter provider [1-7]"
|
||||
read -r provider_idx
|
||||
[ -z "$provider_idx" ] && die "ERROR: provider index cannot be empty"
|
||||
((provider_idx < 1 || provider_idx > 7)) && die "ERROR: provider index must be between 1 and 7"
|
||||
fi
|
||||
while IFS='|' read -ra providers_list; do
|
||||
for p in "${providers_list[@]}"; do
|
||||
if [[ "${p:0:1}" == "$provider_idx" ]]; then
|
||||
lg "provider -> $p | provider index -> $idx" > /dev/stderr
|
||||
provider="${p:3}"
|
||||
break
|
||||
fi
|
||||
((++idx))
|
||||
done
|
||||
done <<< "$providers"
|
||||
[ -z "$provider" ] && provider="mp4upload"
|
||||
inf "Selected provider: $provider"
|
||||
}
|
||||
|
||||
# Check passed in flags and set cli arguments
|
||||
check_flags() {
|
||||
if ((IS_VERBOSE && SILENT)); then
|
||||
@ -293,6 +329,12 @@ check_flags() {
|
||||
if ((IS_RESUME)); then
|
||||
args+=(-r)
|
||||
fi
|
||||
if ((SELECT_PROVIDER)); then
|
||||
get_provider || provider_idx=1
|
||||
lg "PROVIDER INDEX -> $provider_idx"
|
||||
lg "SELECTED PROVIDER -> $provider"
|
||||
args+=(-P"$provider_idx")
|
||||
fi
|
||||
if ((SILENT)); then
|
||||
args+=(-S)
|
||||
fi
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" Automatically generated by Pandoc 2.17.1.1
|
||||
.\" Automatically generated by Pandoc 2.18
|
||||
.\"
|
||||
.\" Define V font for inline verbatim, using C font in formats
|
||||
.\" that render this, and otherwise B font.
|
||||
@ -79,6 +79,9 @@ Display the help message
|
||||
\f[B]-p\f[R]
|
||||
Enable video player selection menu
|
||||
.TP
|
||||
\f[B]-P\f[R]
|
||||
Enable provider selection menu
|
||||
.TP
|
||||
\f[B]-q\f[R]
|
||||
Enable quality selection
|
||||
.TP
|
||||
|
@ -53,6 +53,9 @@ Defaults:
|
||||
**-p**
|
||||
: Enable video player selection menu
|
||||
|
||||
**-P**
|
||||
: Enable provider selection menu
|
||||
|
||||
**-q**
|
||||
: Enable quality selection
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user