Shellcheck suggestions

This commit is contained in:
Nox Sluijtman 2023-05-25 18:10:08 +02:00
parent 9a270533a3
commit 022e278a32
2 changed files with 20 additions and 19 deletions

View file

@ -2,7 +2,7 @@
# Maintainer: Marty Sluijtman <marty.wanderer@disroot.org>
pkgname=arbit
pkgver=1.2
pkgrel=0
pkgrel=2
pkgdesc="A wrapper around yt-dlp, mpv and pipe-viewer to watch aribtrary videos without a browser"
url="https://gitlab.com/EternalWanderer/arbit"
arch="noarch"
@ -23,5 +23,5 @@ package() {
install -Dm 644 zsh.completion "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}
sha512sums="
3bfb46e8ec224d8a8b05a9efa74852a027dd2b89af2f31fab15109f073eaf87c2aca37038f523969a6ea8913c731b7f3574c4dd01e2419863254a6fd2253d33d arbit-1.2.tar.gz
d0f874c0dfc95930fa9023d26aeae556def25d157fd23c0bd9c48c3c8de5e89b5d0b27e0d5aedd96dc4610185ee58177a7948f464a67d71ded597975841eb015 arbit-1.2.tar.gz
"

35
arbit
View file

@ -5,7 +5,7 @@
videoDir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
downloadDir="${ARBITDIR:-$videoDir/YouTube}"
[ -d $downloadDir ] || mkdir -p downloadDir
[ -d "$downloadDir" ] || mkdir -p "$downloadDir"
die(){
if [ -n "$*" ]
@ -21,7 +21,7 @@ getClip(){
mpvClip(){
getClip
if $(echo "${clipboardContent}" | grep -qE 'youtube|youtu.be'); then
if echo "${clipboardContent}" | grep -qE 'youtube|youtu.be'; then
notify-send "Arbit" "Opening clipboard content with 'pipe-viewer'..."
pipe-viewer --player=mpv "${clipboardContent}" || die "Failed to parse URL"
else
@ -39,9 +39,10 @@ clipboardQuery(){
downloadClipUrl(){
getClip
notify-send "Arbit" "Downloading video to ${downloadDir}"
yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" ${clipboardContent} \
&& notify-send "Arbit" "Finished downloading video." \
|| die "Failed to download file"
if yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" "${clipboardContent}"
then notify-send "Arbit" "Finished downloading video."
else die "Failed to download file"
fi
}
search(){
@ -49,28 +50,28 @@ search(){
}
viewUrl(){
url="$(echo $*|sed 's/url //')"
if $(echo "${url}" | grep -qE 'youtube|youtu.be'); then
notify-send "Arbit" "Opening clipboard content with 'pipe-viewer'..."
url="$(echo "$*" | sed 's/url //')"
if echo "${url}" | grep -qE 'youtube|youtu.be'; then
notify-send "Arbit" "Opening URL with 'pipe-viewer'..."
pipe-viewer --player=mpv "${url}" || die "Failed to parse URL"
else
notify-send "Arbit" "Opening clipboard content with 'mpv'..."
notify-send "Arbit" "Opening URL with 'mpv'..."
mpv --force-window "${url}" || die "Failed to parse URL"
fi
}
download(){
url="$(echo $*|sed 's/url //')"
url="$(echo "$*" | sed 's/download //')"
notify-send "Arbit" "Downloading video to ${downloadDir}"
yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" ${url} \
&& notify-send "Arbit" "Finished downloading video." \
|| die "Failed to download file"
if yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" "${url}"
then notify-send "Arbit" "Finished downloading video."
else die "Failed to download file"
fi
}
usage(){
cat >&2 <<EOF
Usage: $(basename $0) <clipboard-url|clipboard-content|download-url|url|download>
Usage: $(basename "$0") <clipboard-url|clipboard-content|download-url|url|download>
clipboard-url: open the contents of clipboard in either 'pipe-viewer' or 'mpv'
clipboard-content: open pipe-viewer with clipboard content as search query
download-url: open 'yt-dlp' with clipboard content and save the result to
@ -87,7 +88,7 @@ case $1 in
clipboard-content) clipboardQuery;;
download-url) downloadClipUrl;;
search) search "$*";;
url)viewUrl $*;;
download)download $*;;
url)viewUrl "$*";;
download)download "$*";;
*) usage;;
esac