Update sab_speed_control.sh

This commit is contained in:
Admin9705
2024-12-09 00:13:26 -05:00
committed by GitHub
parent c46a38f0ca
commit 8dd7a6f2c1

View File

@@ -1,12 +1,21 @@
#!/bin/bash #!/bin/bash
# Configuration # Configuration
SABNZBD_API_KEY="60a7feba60f642d489ed89f08c4f8a88" SABNZBD_API_KEY="60x7fega60f642d489ed89f08c4f8a80fake"
SABNZBD_URL="http://10.0.0.10:8081/sabnzbd/api" SABNZBD_URL="http://10.0.0.10:8081/sabnzbd/api"
SLOW_SPEED="85000000" # 80000000 is 76.3 MB SLOW_SPEED="65000000" # DL Speed when Plex Transcoding
NORMAL_SPEED="105000000" # 125000000 is 118.2 MB NORMAL_SPEED="85000000" # DL Speed when Plex Not Transocding
NIGHT_SPEED="125000000" # DL Speed when not using Internet (such as Night)
# 125000000 is 118.2 MB | 80000000 is 76.3 MB
NIGHT_START="01" # Start hour for nighttime speed (24-hour format) (01 is 0100 AM or 0100hrs)
NIGHT_END="07" # End hour for nighttime speed (24-hour format) (07 is 0700 AM or 0700hrs)
# Type Date in CMD Line to ENSURE that SERVER TIME matches/aligns as a test
CHECK_INTERVAL=10 # Seconds between checks CHECK_INTERVAL=10 # Seconds between checks
TAUTULLI_API_KEY="dad9bbb78bde43249754b630b58fbf7d" TAUTULLI_API_KEY="dad9bbb78bde43249754b630b58fbf7c"
TAUTULLI_URL="http://10.0.0.10:8181/api/v2" TAUTULLI_URL="http://10.0.0.10:8181/api/v2"
# Function to set SABnzbd speed limit # Function to set SABnzbd speed limit
@@ -43,9 +52,20 @@ is_plex_playing() {
# Monitoring loop # Monitoring loop
while true; do while true; do
if is_plex_playing; then if is_plex_playing; then
# If Plex is playing/transcoding, use SLOW_SPEED
set_sab_speed "${SLOW_SPEED}" set_sab_speed "${SLOW_SPEED}"
else else
# If Plex is not playing/transcoding, check the current hour
current_hour=$(date +%H)
# Compare current hour to NIGHT_START and NIGHT_END
if [ "${current_hour}" -ge "${NIGHT_START}" ] && [ "${current_hour}" -lt "${NIGHT_END}" ]; then
# If current time is between NIGHT_START and NIGHT_END (exclusive of NIGHT_END), use NIGHT_SPEED
set_sab_speed "${NIGHT_SPEED}"
else
# Otherwise, use NORMAL_SPEED
set_sab_speed "${NORMAL_SPEED}" set_sab_speed "${NORMAL_SPEED}"
fi fi
fi
sleep "${CHECK_INTERVAL}" sleep "${CHECK_INTERVAL}"
done done