Skip to content

Commit

Permalink
feat: initial logger support (#1370)
Browse files Browse the repository at this point in the history
Co-authored-by: port19 <[email protected]>
  • Loading branch information
71zenith and port19x authored Aug 26, 2024
1 parent 5e4ad5c commit 2f40d6a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ani-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version_number="4.8.13"
version_number="4.9.0"

# UI

Expand Down Expand Up @@ -45,6 +45,8 @@ help_info() {
Download the video instead of playing it
-D, --delete
Delete history
-l, --logview
Show logs
-s, --syncplay
Use Syncplay to watch with friends
-S, --select-nth
Expand Down Expand Up @@ -256,6 +258,7 @@ download() {
}

play_episode() {
[ "$log_episode" = 1 ] && [ "$player_function" != "debug" ] && [ "$player_function" != "download" ] && command -v logger >/dev/null && logger -t ani-cli "${allanime_title}${ep_no}"
[ "$skip_intro" = 1 ] && skip_flag="$(ani-skip -q "$mal_id" -e "$ep_no")"
[ -z "$episode" ] && get_episode_url
# shellcheck disable=SC2086
Expand Down Expand Up @@ -327,6 +330,7 @@ allanime_base="allanime.day"
allanime_api="https://api.${allanime_base}"
mode="${ANI_CLI_MODE:-sub}"
download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
log_episode="${ANI_CLI_LOG:-1}"
quality="${ANI_CLI_QUALITY:-best}"
case "$(uname -a)" in
*Darwin*) player_function="$(where_iina)" ;; # mac OS
Expand Down Expand Up @@ -386,6 +390,14 @@ while [ $# -gt 0 ]; do
: >"$histfile"
exit 0
;;
-l | --logview)
case "$(uname -s)" in
Darwin*) log show --predicate 'process == "logger"' ;;
Linux*) journalctl -t ani-cli ;;
*) die "Logger not implemented for your platform" ;;
esac
exit 0
;;
-V | --version) version_info ;;
-h | --help) help_info ;;
-e | --episode | -r | --range)
Expand Down
6 changes: 6 additions & 0 deletions ani-cli.1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Download episode.
\fB\-D | --delete\fR
Delete history.
.TP
\fB\-l | --logview\fR
Show logs.
.TP
\fB\-h | --help\fR
Show summary of options.
.TP
Expand Down Expand Up @@ -86,6 +89,9 @@ Sets the player ani-cli uses. Can be debug (print links), download (equivalent t
\fBANI_CLI_EXTERNAL_MENU\fR
Controls the frontend of ani-cli. Can be 0 (uses fzf) or 1 (uses rofi dmenu). Default is 0.
.TP
\fBANI_CLI_LOG_EPISODE\fR
Controls the logging feature for playback. Can be 1(logs) or 0(doesn't log). Default is 1.
.TP
\fBANI_CLI_MULTI_SELECTION\fR
Controls the multi flag for the chosen frontend. Default is -m for fzf and --multi-select for rofi dmenu.
.TP
Expand Down

0 comments on commit 2f40d6a

Please sign in to comment.