Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial logger support #1370

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.10"
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 @@ -249,6 +251,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 @@ -320,6 +323,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="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
Expand Down Expand Up @@ -379,6 +383,14 @@ while [ $# -gt 0 ]; do
: >"$histfile"
exit 0
;;
-l | --logview)
case "$(uname -s)" in
Darwin*) log show --predicate 'eventMessage contains "ani-cli"' --info ;;
port19x marked this conversation as resolved.
Show resolved Hide resolved
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
Loading