[cliplumber] Add scribblehub crawling
This commit is contained in:
parent
25242a0cc2
commit
938d3afc62
1 changed files with 25 additions and 7 deletions
|
@ -32,18 +32,24 @@ urls="$(echo $clip | grep -o 'https\?://[a-zA-Z0-9~#%&_+=,.?/-]\+')"
|
||||||
# Check the requirements for every option
|
# Check the requirements for every option
|
||||||
opts="rot13"
|
opts="rot13"
|
||||||
check_exists "$TERM_EMU" "mpv" "youtube-dl" &&
|
check_exists "$TERM_EMU" "mpv" "youtube-dl" &&
|
||||||
opts="$(printf "audio-search\n%s" "$opts")"
|
opts="audio-search|$opts"
|
||||||
check_exists "dragon" &&
|
check_exists "dragon" &&
|
||||||
opts="$(printf "drag-n-drop\n%s" "$opts")"
|
opts="drag-n-drop|$opts"
|
||||||
# Enable additional features when the clipboard contains an URL
|
# Enable additional features when the clipboard contains an URL
|
||||||
if [ -n "$urls" ] && check_exists "youtube-dl"; then
|
if [ -n "$urls" ] && check_exists "youtube-dl"; then
|
||||||
check_exists "mpv" &&
|
if echo "$urls" | grep -qF "scribblehub.com"; then
|
||||||
opts="$(printf "play\n%s" "$opts")"
|
check_exists "lncrawl" && opts="crawl|$opts"
|
||||||
opts="$(printf "download\n%s" "$opts")"
|
else
|
||||||
|
check_exists "mpv" && opts="play|$opts"
|
||||||
|
opts="download|$opts"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Load default choice last
|
# Load default choice last
|
||||||
check_exists "qrencode" "feh" &&
|
check_exists "qrencode" "feh" &&
|
||||||
opts="$(printf "qr\n%s" "$opts")"
|
opts="qr|$opts"
|
||||||
|
|
||||||
|
# Split into multiple lines for dmenu
|
||||||
|
opts="$(printf "%s" "$opts" | sed 's/|/\n/g')"
|
||||||
|
|
||||||
choice="$(printf "%s" "$opts" | dmenu -p "$(printf "%s" "$clip" | cut -c 1-48)")"
|
choice="$(printf "%s" "$opts" | dmenu -p "$(printf "%s" "$clip" | cut -c 1-48)")"
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
|
@ -55,9 +61,21 @@ 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" "$clip" 2>&1 | grep 'ERROR:' | xargs -n1 -d "\n" notify-send
|
youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$urls" 2>&1 | grep 'ERROR:' | xargs -n1 -d "\n" notify-send
|
||||||
#notify-send "Error while downloading: $clip"
|
#notify-send "Error while downloading: $clip"
|
||||||
;;
|
;;
|
||||||
|
"crawl")
|
||||||
|
path="$HOME/books/"
|
||||||
|
[ -d "$path" ] || mkdir -p "$path"
|
||||||
|
cd "$path" || exit
|
||||||
|
out="$(lncrawl --single --all --format epub --filename-only --suppress -s "$urls" | grep -vFe "Input is suppressed" -e "Namespace(")"
|
||||||
|
errors="$(printf "%s" "$out" | grep -Fe " ❗ ")"
|
||||||
|
if [ -n "$errors" ]; then
|
||||||
|
printf "%s" "$errors" | xargs -n1 -d "\n" notify-send
|
||||||
|
else
|
||||||
|
printf "%s" "$out" | sed -ne '/^NOVEL: /s/NOVEL: \(.*\)/Successfully crawled "\1"/p' | xargs -0 -n1 notify-send
|
||||||
|
fi
|
||||||
|
;;
|
||||||
"drag-n-drop"*)
|
"drag-n-drop"*)
|
||||||
dragon -x "$clip"
|
dragon -x "$clip"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue