Compare commits

..

No commits in common. "5804f84f8327884efdb68f519d778d982a5932ed" and "da45bf15fefa34825b65488a71f73c4a9647e63d" have entirely different histories.

7 changed files with 60 additions and 91 deletions

View File

@ -145,7 +145,6 @@ aniwrapper -c # Use ani-cli command-line mode (rofi disabled)
aniwrapper -C # Connect to history database
aniwrapper -d # Download anime in command-line mode
aniwrapper -d <query> # Run in download mode (best quality), searching for <query>
aniwrapper -e <episode> or <begin_episode - end_episode>
aniwrapper -f <starting_directory> # Specify starting directory for play_from_file mode, bypassing main menu
aniwrapper -h # Show help menu
aniwrapper -p # Enable player selection menu
@ -263,6 +262,37 @@ Change aniwrapper theme
</details>
## ani-cli
```
# watch anime
ani-cli <query>
# verbose logging
ani-cli -v
# download anime
ani-cli -d <download_directory>
# resume watching anime
ani-cli -H
# sync history across devices
ani-cli -s
# choose quality
ani-cli -q <best (default)|1080p|720p|480p|360p|worst>
# choose rofi theme from presets
ani-cli -t <aniwrapper (default)|dracula|fancy|material|monokai|nord|nord2|onedark>
# Specify starting directory for play_from_file mode (does not work with -c)
ani-cli -f <starting_directory>
# run ani-cli in command-line mode (rofi disabled)
ani-cli -c
```
# Themes
<div align="center">

66
ani-cli
View File

@ -12,12 +12,10 @@ ROFI_THEME="aniwrapper.rasi"
THEMES="alter|aniwrapper|dracula|doomone|fancy|material|monokai|nord|nord2|onedark"
TMPDIR="${XDG_CACHE_HOME:-$HOME/.cache}/aniwrapper-temp"
DPI=96
GET_QUALITY=0
IS_ROFI=1
VERBOSE=0
SILENT=0
FIRST_EP_NUMBER=1
NEW_QUALITY=0
PLAYER_FN="mpv"
PID=0
@ -184,14 +182,8 @@ get_video_link() {
: $((i += 1))
done
if printf '%s' "$result_links" | grep -q "m3u8"; then
lg "Using m3u8 link"
# if a new quality has not been selected already, then get video quality
# from user
((GET_QUALITY && !NEW_QUALITY)) && set_video_quality
get_video_quality_m3u8 "$result_links"
else
lg "Using mp4 link"
((GET_QUALITY && !NEW_QUALITY)) && set_video_quality
video_url=$(get_video_quality_mp4 "$result_links")
fi
unset result_links
@ -231,7 +223,6 @@ process_search() {
episode_list() {
select_ep_result=$(curl -A "$AGENT" -s "$BASE_URL/v1/$1" | sed -nE "s_.*epslistplace.*>(.*)</div>_\1_p" | tr "," "\n" | sed -e '/extra/d' -e '/PV/d' | sed -nE 's_".*":"(.*)".*_\1_p')
lg "Select Episode Result: $select_ep_result"
FIRST_EP_NUMBER=1
[ -z "$select_ep_result" ] && LAST_EP_NUMBER=0 || LAST_EP_NUMBER=$(printf "%s\n" "$select_ep_result" | wc -l)
lg "First Ep #: $FIRST_EP_NUMBER | Last Ep #: $LAST_EP_NUMBER"
@ -308,24 +299,6 @@ open_episode() {
fi
}
# Sets $ep_choice_start = 1 if only one episode exists
# else call episode_selection
get_episode() {
[[ "$LAST_EP_NUMBER" -eq 0 ]] && die "Episodes not released yet for $anime_id"
if ((!is_select_episodes)); then
read -r ep_choice_start ep_choice_end <<< "${episodes//-/}"
# error if ep_choice_start is not a number
[[ -z "$ep_choice_start" || ! "$ep_choice_start" =~ ^[0-9]+$ ]] && die "Invalid episode number: ${ep_choice_start:-NULL}"
# if ep_choice_end is not a number, set it to ep_choice_start
[[ -n "$ep_choice_end" && ! "$ep_choice_end" =~ ^[0-9]+$ ]] && ep_choice_end="$ep_choice_start"
elif (((FIRST_EP_NUMBER == LAST_EP_NUMBER && (FIRST_EP_NUMBER == 0 || FIRST_EP_NUMBER == 1)))); then
ep_choice_start=1
else
episode_selection
fi
}
stream() {
lg "Running stream()"
if [ "$#" -eq 0 ]; then
@ -349,18 +322,21 @@ stream() {
die "No anime selection found"
fi
fi
get_episode
if (((FIRST_EP_NUMBER == LAST_EP_NUMBER && (FIRST_EP_NUMBER == 0 || FIRST_EP_NUMBER == 1)))); then
ep_choice_start=1
else
episode_selection
fi
}
parse_args() {
download_dir="."
scrape=query
quality=best
is_select_episodes=1
is_download=0
is_resume=0
is_autoplay=0
while getopts 'ad:e:Hsvqcf:t:T:CQ:D:Sp:P:rR' OPT; do
while getopts 'ad:Hsvq:cf:t:T:CQ:D:Sp:P:rR' OPT; do
case "$OPT" in
a)
is_autoplay=1
@ -370,11 +346,6 @@ parse_args() {
download_dir="$OPTARG"
lg "DOWNLOAD DIR: $download_dir"
;;
e)
episodes="$OPTARG"
[[ "$episodes" =~ ^[0-9]+(-[0-9]+)? ]] || die "Invalid episode range: $episodes"
is_select_episodes=0
;;
r)
is_resume=1
;;
@ -391,7 +362,8 @@ parse_args() {
VERBOSE=1
;;
q)
GET_QUALITY=1
quality="$OPTARG"
lg "passed in quality: $quality"
;;
c)
IS_ROFI=0
@ -489,7 +461,7 @@ show_menu() {
;;
s)
get_episode
episode_selection
episode=$ep_choice_start
;;
@ -517,8 +489,7 @@ show_menu() {
is_download=1
;;
q)
lg "Exiting..."
exit 0
break
;;
*)
@ -606,7 +577,7 @@ main() {
anime_name="${updated_episode%%/*}"
lg "ANIME NAME: $anime_name"
if ! check_db "search" "$anime_name"; then
stmt="SELECT COUNT(*) FROM search_history WHERE anime_name = '$anime_name';"
stmt="SELECT COUNT(*) FROM watch_history WHERE anime_name = '$anime_name' AND episode_number = '${updated_episode##*/ep}';"
lg "QUERY: $stmt"
if [[ "$(run_stmt "$stmt")" -ne 0 ]]; then
lg "$updated_episode watched before... adding to watched list"
@ -622,9 +593,11 @@ main() {
die "No selection made"
fi
lg "SELECTION: $selection"
# get everything before -episode-
selection_id="${selection%%/*}"
# get everything after -episode-
ep_choice_start="${selection##*/ep}"
episode_list "$selection_id"
get_episode
;;
esac
@ -632,17 +605,14 @@ main() {
for ep in $episodes; do
open_episode "$selection_id" "$ep" "$download_dir"
if ((!is_autoplay && is_select_episodes)); then
show_menu
else
wait
fi
((is_download)) && sleep 2
sleep 2
done
if ((is_download)); then
notification "Finished downloading episodes: $episodes for $selection_id... exiting"
lg "Finished downloading episodes: $episodes for $selection_id... exiting"
exit 0
elif ((!is_autoplay)); then
show_menu
fi
}

View File

@ -8,7 +8,7 @@ CFG_FILE="$CFG_DIR/themes/aniwrapper.rasi"
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
ROFI_THEME="aniwrapper.rasi"
THEMES="alter|aniwrapper|dracula|doomone|fancy|material|monokai|nord|nord2|onedark"
QUALITIES="1. best|2. worst"
QUALITIES="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
SUPPORTED_PLAYERS="mpv|vlc"
QUALITY=best
PLAYER_FN=mpv
@ -22,7 +22,6 @@ IS_ROFI=1
IS_SYNC=0
IS_ALTERNATE_PLAYER=0
IS_VERBOSE=0
IS_SELECT_EPISODE=1
SELECT_PROVIDER=0
SILENT=0
@ -35,9 +34,9 @@ help_text() {
printf "%s\n" "$line"
done <<< "
Usage:
aniwrapper [-adehpqSv] [-t <theme> | -T <config_path>] [<query>]
aniwrapper [-adhpqSv] [-t <theme> | -T <config_path>] [<query>]
aniwrapper -f <directory_path> [-t <theme> | -T <config_path>] [-pSv] [<query>]\
aniwrapper -c [-dehpqSv] [<query>]
aniwrapper -c [-dhpqSv] [<query>]
aniwrapper -Q <query>
aniwrapper -C
Options:
@ -45,7 +44,6 @@ Options:
-c enable command-line mode (rofi disabled)
-C connect to history database
-d download episode in command-line mode
-e [<episode> | <begin> - <end>] select episode(s) to stream/download
-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
@ -87,6 +85,9 @@ quit() {
}
run() {
if ((!IS_PLAY_FROM_FILE && !IS_SYNC && GET_QUALITY)); then
get_quality
fi
if ((IS_CUSTOM_THEME)); then
args+=(-T"$CFG_FILE")
elif ((!IS_CUSTOM_THEME)); then
@ -105,7 +106,7 @@ get_quality() {
-sep '|' -no-custom <<< "$QUALITIES")
QUALITY=$(awk '{print $2}' <<< "$selection")
else
qualities="best|worst"
qualities="best|1080p|720p|480p|360p|worst"
prompt "Choose quality " "[$qualities]"
read -r QUALITY
while [[ ! "$QUALITY" =~ ($qualities) ]]; do
@ -156,7 +157,7 @@ set_theme() {
}
parse_args() {
while getopts 'acCdD:e:f:hpPqQ:rSt:T:v' OPT; do
while getopts 'acCdD:f:hpPqQ:rSt:T:v' OPT; do
case "$OPT" in
a)
IS_AUTOPLAY=1
@ -177,11 +178,6 @@ parse_args() {
D)
DPI="$OPTARG"
;;
e)
episodes="$OPTARG"
[[ "$episodes" =~ ^[0-9]+(-[0-9]+)? ]] || die "Invalid episode range: $episodes"
IS_SELECT_EPISODE=0
;;
f)
IS_PLAY_FROM_FILE=1
play_path="$OPTARG"
@ -346,12 +342,6 @@ check_flags() {
if ((IS_VERBOSE)); then
args+=(-v)
fi
if ((GET_QUALITY)); then
args+=(-q)
fi
if ((!IS_SELECT_EPISODE)); then
args+=(-e"$episodes")
fi
lg "ARGS: ${args[*]}"
if ((IS_AUTOPLAY || IS_DOWNLOAD || !IS_ROFI || IS_RESUME || IS_PLAY_FROM_FILE)); then

View File

@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 2.19.2
.\" Automatically generated by Pandoc 2.18
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
@ -70,9 +70,6 @@ Connect to the history database
\f[B]-d\f[R]
Enable downloading anime in command-line mode
.TP
\f[B]-e\f[R] \f[I]episode\f[R] \f[B]or\f[R] \f[I]begin_episode - end_episode\f[R]
Select episode(s) to stream/download
.TP
\f[B]-f\f[R]
Specify the starting search directory for \[lq]Play from File\[rq] mode
.TP

View File

@ -44,9 +44,6 @@ Defaults:
**-d**
: Enable downloading anime in command-line mode
**-e** _episode_ **or** _begin_episode - end_episode_
: Select episode(s) to stream/download
**-f**
: Specify the starting search directory for "Play from File" mode

View File

@ -143,7 +143,7 @@ get_dl_dir() {
# sets the video quality
set_video_quality() {
qualities="best|worst"
((IS_MP4)) && qualities="best|1080p|720p|480p|360p|worst" || qualities="best|worst"
prompt "Choose quality [$qualities]"
read -r quality
while [[ ! "$quality" =~ ($qualities) ]]; do
@ -152,20 +152,6 @@ set_video_quality() {
read -r quality
done
[ -z "$quality" ] && die "No quality selected"
NEW_QUALITY=1
}
# gets the video quality from the user
get_quality() {
qualities="best|worst"
prompt "Choose quality " "[$qualities]"
read -r quality
while [[ ! "$quality" =~ ($qualities) ]]; do
lg "$quality not a valid quality -> [$qualities]"
prompt "Choose quality " "[$qualities]"
read -r quality
done
lg "selected quality: $quality"
}
# vim :ft=sh

View File

@ -192,7 +192,7 @@ get_dl_dir() {
# sets the video quality
set_video_quality() {
qualities="1. best|2. worst"
((IS_MP4)) && qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst" || qualities="1. best|2. worst"
while IFS='|' read -ra quals; do
for q in "${quals[@]}"; do
if [[ "$(awk '{ print $NF }' <<< "$q")" == "$quality" ]]; then
@ -206,7 +206,6 @@ set_video_quality() {
-i -l 6 -no-custom -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
-p "Choose quality:" -window-title 'aniwrapper' -selected-row "$cur_quality" <<< "$qualities")
quality=$(awk '{ print $2 }' <<< "$choice")
NEW_QUALITY=1
}
# vim :ft=sh