mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Use parallel
This commit is contained in:
parent
d2256b18e4
commit
2df6500045
16
qbth
16
qbth
@ -4,7 +4,7 @@
|
||||
|
||||
# Dependency check
|
||||
missing_deps=()
|
||||
for bin in "gum" "jq" "lynx" "qbt"; do
|
||||
for bin in "gum" "jq" "lynx" "parallel" "qbt"; do
|
||||
if ! test -x "$(command -v $bin)"; then
|
||||
missing_deps+=("$bin")
|
||||
fi
|
||||
@ -19,20 +19,16 @@ fi
|
||||
function add_torrents() {
|
||||
torrents=("$@")
|
||||
|
||||
for url in "${torrents[@]}"; do
|
||||
if qbt torrent add url "$url"; then
|
||||
gum log -l info -t ansic "Added $(basename "$url")"
|
||||
else
|
||||
gum log -l error -t ansic "Error adding $(basename "$url")"
|
||||
fi
|
||||
done
|
||||
parallel qbt torrent add url ::: "${torrents[@]}"
|
||||
for url in "${torrents[@]}"; do gum log -l info "Added" "$(basename $url)"; done
|
||||
}
|
||||
|
||||
function delete_torrents() {
|
||||
if test -n "$1"; then
|
||||
echo "$1" | xargs -I _ sh -c "qbt torrent delete --with-files _ && gum log -l info -t ansic 'Deleted' _"
|
||||
echo "$1" | parallel "qbt torrent delete --with-files {}"
|
||||
echo "$1" | xargs -I _ gum log -l info "Deleted" _
|
||||
else
|
||||
gum log -l info -t ansic "Nothing to do."
|
||||
gum log -l info "Nothing to do."
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user