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
|
# Dependency check
|
||||||
missing_deps=()
|
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
|
if ! test -x "$(command -v $bin)"; then
|
||||||
missing_deps+=("$bin")
|
missing_deps+=("$bin")
|
||||||
fi
|
fi
|
||||||
@ -19,20 +19,16 @@ fi
|
|||||||
function add_torrents() {
|
function add_torrents() {
|
||||||
torrents=("$@")
|
torrents=("$@")
|
||||||
|
|
||||||
for url in "${torrents[@]}"; do
|
parallel qbt torrent add url ::: "${torrents[@]}"
|
||||||
if qbt torrent add url "$url"; then
|
for url in "${torrents[@]}"; do gum log -l info "Added" "$(basename $url)"; done
|
||||||
gum log -l info -t ansic "Added $(basename "$url")"
|
|
||||||
else
|
|
||||||
gum log -l error -t ansic "Error adding $(basename "$url")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_torrents() {
|
function delete_torrents() {
|
||||||
if test -n "$1"; then
|
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
|
else
|
||||||
gum log -l info -t ansic "Nothing to do."
|
gum log -l info "Nothing to do."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user