diff options
Diffstat (limited to 'bin/common')
-rwxr-xr-x | bin/common/ask | 38 | ||||
-rwxr-xr-x | bin/common/targit | 5 | ||||
-rwxr-xr-x | bin/common/ytclipo | 12 |
3 files changed, 13 insertions, 42 deletions
diff --git a/bin/common/ask b/bin/common/ask index 9fb04ce..95530f5 100755 --- a/bin/common/ask +++ b/bin/common/ask @@ -1,36 +1,4 @@ #!/bin/sh - -# requirements -which pass jq > /dev/null || - exit 1 - -# input -test -z "${inp:=$@}" && - inp="$(cat /dev/stdin)" - -# \n\t -> ' ' && "->' -prompt="$(echo "$inp" | tr "\n\t\"" " '")" -test -z "$prompt" && exit 1 - -API_KEY="$(pass tokens/openai-api)" -model="text-davinci-003" -tokens="1024" -temperature=0 - -data=$(echo \ -'{ - "prompt": "'"$prompt"'", - "model": "'"$model"'", - "max_tokens": '$tokens', - "temperature": '$temperature' -}') - -output=$(curl -s -X POST \ - -H 'Content-Type: application/json' \ - -H "Authorization: Bearer $API_KEY" \ - -d "$data" \ - https://api.openai.com/v1/completions \ - | jq -r '.choices[0].text') - -# remove newline -echo "${output:1}" +which tgpt >/dev/null || exit 1 +[ "${inp:=$@}" ] || inp="$(cat /dev/stdin)" +tgpt "$inp" diff --git a/bin/common/targit b/bin/common/targit index ae046ac..ca560b3 100755 --- a/bin/common/targit +++ b/bin/common/targit @@ -1,6 +1,5 @@ #!/bin/sh -pwd=$(pwd) root="$(git rev-parse --show-toplevel)" cd "$root" || exit 1 -file="$(basename "$root" | sed 's/^\.//').tar.gz" -tar czf "$pwd/$file" $(git ls-files) +file="${root##*/}".tar.gz +tar czf "$file" $(git ls-files) diff --git a/bin/common/ytclipo b/bin/common/ytclipo index 5d86c3f..959ee21 100755 --- a/bin/common/ytclipo +++ b/bin/common/ytclipo @@ -11,9 +11,13 @@ fi inp="$1" [ "${inp:=$(paste)}" ] || inp="$(cat /dev/stdin)" -# take last link from clipboard -# works when link is from yt-local -inp="https://youtu.be/$(echo "$inp" | sed 's/.*\(.\{11\}\)$/\1/')" +# remove util scheme +inp="${inp#*//}" +# convert to youtube.com/path url +# works for: +# - 'youtu.be/watch?v=xxxxxx' +# - 'https://piped.video/watch?v=xxxxx' +inp="https://youtube.com/${inp#*/}" >&2 printf "inp: %s\n" "$inp" notify-send "ytclipo" "downloading <i>$inp</i>" || : @@ -23,5 +27,5 @@ yt-dlp "$inp" \ -f "b" \ -S "res:1080" \ -P "$HOME/vids/youtube/" \ - -o "%(channel)s - %(title)s.%(ext)s" + -o "%(channel)s/%(title)s.%(ext)s" notify-send "ytclipo" "finished downloading." || : |