-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck4kTranscode.sh
More file actions
27 lines (23 loc) · 985 Bytes
/
Copy pathcheck4kTranscode.sh
File metadata and controls
27 lines (23 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Path to the kill_script.py
killscript_path="<PATH KILLSCRIPT>" #Change it to the path of killscript
get_actual_4k_transcode_count() {
local tautulli_apikey="$TAUTULLI_APIKEY"
local tautulli_url="$TAUTULLI_URL/api/v2"
local api_endpoint="${tautulli_url}?cmd=get_activity&apikey=${tautulli_apikey}"
local response=$(curl -s "${api_endpoint}")
# Count the number of 4K transcodes
local transcode_count=$(echo "$response" | python -c "import sys, json
data = json.load(sys.stdin)
count = sum(1 for session in data['response']['data']['sessions'] if session['video_resolution'] == '4k' and session['transcode_decision'] == 'transcode')
print(count)
")
echo $transcode_count
}
# Main logic
current_transcodes=$(get_actual_4k_transcode_count)
echo "$current_transcodes stream 4K currently playing"
if [ "$current_transcodes" -ge 2 ]; then
echo "A 4K transcode is already in progress. Calling killscript"
python $killscript_path "$@"
fi