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> # Maintainer: Marty Sluijtman <marty.wanderer@disroot.org>
pkgname=arbit pkgname=arbit
pkgver=1.2 pkgver=1.2
pkgrel=0 pkgrel=2
pkgdesc="A wrapper around yt-dlp, mpv and pipe-viewer to watch aribtrary videos without a browser" pkgdesc="A wrapper around yt-dlp, mpv and pipe-viewer to watch aribtrary videos without a browser"
url="https://gitlab.com/EternalWanderer/arbit" url="https://gitlab.com/EternalWanderer/arbit"
arch="noarch" arch="noarch"
@ -23,5 +23,5 @@ package() {
install -Dm 644 zsh.completion "$pkgdir"/usr/share/zsh/site-functions/_$pkgname install -Dm 644 zsh.completion "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
} }
sha512sums=" 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}" videoDir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
downloadDir="${ARBITDIR:-$videoDir/YouTube}" downloadDir="${ARBITDIR:-$videoDir/YouTube}"
[ -d $downloadDir ] || mkdir -p downloadDir [ -d "$downloadDir" ] || mkdir -p "$downloadDir"
die(){ die(){
if [ -n "$*" ] if [ -n "$*" ]
@ -21,7 +21,7 @@ getClip(){
mpvClip(){ mpvClip(){
getClip 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'..." notify-send "Arbit" "Opening clipboard content with 'pipe-viewer'..."
pipe-viewer --player=mpv "${clipboardContent}" || die "Failed to parse URL" pipe-viewer --player=mpv "${clipboardContent}" || die "Failed to parse URL"
else else
@ -39,9 +39,10 @@ clipboardQuery(){
downloadClipUrl(){ downloadClipUrl(){
getClip getClip
notify-send "Arbit" "Downloading video to ${downloadDir}" notify-send "Arbit" "Downloading video to ${downloadDir}"
yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" ${clipboardContent} \ if yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" "${clipboardContent}"
&& notify-send "Arbit" "Finished downloading video." \ then notify-send "Arbit" "Finished downloading video."
|| die "Failed to download file" else die "Failed to download file"
fi
} }
search(){ search(){
@ -49,28 +50,28 @@ search(){
} }
viewUrl(){ viewUrl(){
url="$(echo $*|sed 's/url //')" url="$(echo "$*" | sed 's/url //')"
if $(echo "${url}" | grep -qE 'youtube|youtu.be'); then if echo "${url}" | grep -qE 'youtube|youtu.be'; then
notify-send "Arbit" "Opening clipboard content with 'pipe-viewer'..." notify-send "Arbit" "Opening URL with 'pipe-viewer'..."
pipe-viewer --player=mpv "${url}" || die "Failed to parse URL" pipe-viewer --player=mpv "${url}" || die "Failed to parse URL"
else 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" mpv --force-window "${url}" || die "Failed to parse URL"
fi fi
} }
download(){ download(){
url="$(echo $*|sed 's/url //')" url="$(echo "$*" | sed 's/download //')"
notify-send "Arbit" "Downloading video to ${downloadDir}" notify-send "Arbit" "Downloading video to ${downloadDir}"
yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" ${url} \ if yt-dlp -o "${downloadDir}/%(title)s - %(uploader)s.%(ext)s" "${url}"
&& notify-send "Arbit" "Finished downloading video." \ then notify-send "Arbit" "Finished downloading video."
|| die "Failed to download file" else die "Failed to download file"
fi
} }
usage(){ usage(){
cat >&2 <<EOF 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-url: open the contents of clipboard in either 'pipe-viewer' or 'mpv'
clipboard-content: open pipe-viewer with clipboard content as search query clipboard-content: open pipe-viewer with clipboard content as search query
download-url: open 'yt-dlp' with clipboard content and save the result to download-url: open 'yt-dlp' with clipboard content and save the result to
@ -87,7 +88,7 @@ case $1 in
clipboard-content) clipboardQuery;; clipboard-content) clipboardQuery;;
download-url) downloadClipUrl;; download-url) downloadClipUrl;;
search) search "$*";; search) search "$*";;
url)viewUrl $*;; url)viewUrl "$*";;
download)download $*;; download)download "$*";;
*) usage;; *) usage;;
esac esac