|
|
@ -1,22 +1,14 @@ |
|
|
#!/bin/sh |
|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
# Load helper functions |
|
|
|
|
|
source "$(dirname "$(rreadlink "$0")")/../lib/utils.sh" |
|
|
|
|
|
|
|
|
# TODO: detect term or set it globally |
|
|
# TODO: detect term or set it globally |
|
|
TERM_EMU="kitty" |
|
|
TERM_EMU="kitty" |
|
|
|
|
|
|
|
|
die() { |
|
|
if ! check_exists wl-paste && [ ! -z "$WAYLAND_DISPLAY" ]; then |
|
|
notify-send "$@" |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
check_exists() { |
|
|
|
|
|
for c in $@; do |
|
|
|
|
|
which "$c" > /dev/null 2>&1 || return 1 |
|
|
|
|
|
done |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ! which wl-paste > /dev/null 2>&1 && [ ! -z "$WAYLAND_DISPLAY" ]; then |
|
|
|
|
|
die "Wayland detected and wl-paste not found" |
|
|
die "Wayland detected and wl-paste not found" |
|
|
elif ! which xsel > /dev/null 2>&1 && [ -z "$WAYLAND_DISPLAY" ]; then |
|
|
elif ! check_exists xsel && [ -z "$WAYLAND_DISPLAY" ]; then |
|
|
die "xsel not found" |
|
|
die "xsel not found" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
@ -61,7 +53,7 @@ case "$choice" in |
|
|
path="$HOME/mus/$(printf "%s" "$choice" | cut -d " " -f 2-)" |
|
|
path="$HOME/mus/$(printf "%s" "$choice" | cut -d " " -f 2-)" |
|
|
[ -d "$path" ] || mkdir -p "$path" |
|
|
[ -d "$path" ] || mkdir -p "$path" |
|
|
cd "$path" || exit |
|
|
cd "$path" || exit |
|
|
youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$urls" 2>&1 | grep 'ERROR:' | tee /dev/fd/2 | xargs -n1 -d "\n" notify-send |
|
|
youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$urls" 2>&1 | grep 'ERROR:' | notify_err |
|
|
;; |
|
|
;; |
|
|
"crawl") |
|
|
"crawl") |
|
|
path="$HOME/books/" |
|
|
path="$HOME/books/" |
|
|
@ -70,7 +62,7 @@ case "$choice" in |
|
|
out="$(lncrawl --single --all --format epub --filename-only --suppress -s "$urls" | grep -vFe "Input is suppressed" -e "Namespace(")" |
|
|
out="$(lncrawl --single --all --format epub --filename-only --suppress -s "$urls" | grep -vFe "Input is suppressed" -e "Namespace(")" |
|
|
errors="$(printf "%s" "$out" | grep -Fe " ❗ ")" |
|
|
errors="$(printf "%s" "$out" | grep -Fe " ❗ ")" |
|
|
if [ -n "$errors" ]; then |
|
|
if [ -n "$errors" ]; then |
|
|
printf "%s" "$errors" | xargs -n1 -d "\n" notify-send |
|
|
printf "%s" "$errors" | notify_err |
|
|
else |
|
|
else |
|
|
printf "%s" "$out" | sed -ne '/^NOVEL: /s/NOVEL: \(.*\)/Successfully crawled "\1"/p' | xargs -0 -n1 notify-send |
|
|
printf "%s" "$out" | sed -ne '/^NOVEL: /s/NOVEL: \(.*\)/Successfully crawled "\1"/p' | xargs -0 -n1 notify-send |
|
|
fi |
|
|
fi |
|
|
|