Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions manual-tracker-add.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
# Get transmission credentials
auth=${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password}
# Get transmission credentials, if set
if [[ -n "$TRANSMISSION_USER" && -n "$TRANSMISSION_PASS" ]]; then
auth="${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password}"
else
auth=
fi
host=${TRANSMISSION_HOST:-localhost}
list_url=${TRACKER_URL:-https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt}

Expand All @@ -15,7 +19,7 @@ add_trackers () {
for tracker in $(curl --location -# "${base_url}") ; do
echo -en "\e[0m"
echo -ne "\e[93m*\e[0m ${tracker}..."
if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
echo -e '\e[91m failed.'
echo -en "\e[0m"
else
Expand All @@ -27,10 +31,10 @@ done
}

# Get list of active torrents
ids=${1:-"$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"}
ids=${1:-"$(transmission-remote "$host" ${auth:+--auth="$auth"} --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"}

for id in $ids ; do
hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
hash="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
torrent_name="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
add_trackers "$hash"
done