diff --git a/qbth b/qbth index 9430a7b..b6f05ae 100755 --- a/qbth +++ b/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 }