***
```
#!/bin/bash
tvh_data_path="/home/hts/.hts"
profile="pass"
admin_pass="user:user"
user_pass="r61:r61"
host="localhost:9981"
file_name="_all_enabled_services.m3u"
date_time=`date '+%d-%B-%Y_%H-%M'`
# Для работы с JSON использую jq apt-get install jq
wget -O /tmp/services_unsorted.json http://$admin_pass@localhost:9981/api/mpegts/service/grid?limit=100000
/usr/bin/jq '.entries |= sort_by(.network, .multiplex, .svcname)' /tmp/services_unsorted.json > /tmp/services.json
echo \#EXTM3U | tee -a # tee выводит данные из потока ввода в поток вывода и дублирует эти данные в указанные файлы
# tee -a дописать в заданные ФАЙЛЫ
entries=$(/usr/bin/jq -c '.total' /tmp/services.json)
for (( service=0; service<= $entries; service++ ))
do
enabled=$(/usr/bin/jq -c '.entries['$service'].enabled' /tmp/services.json)
if [ "$enabled" = "true" ]
then
svcname=$(/usr/bin/jq -c -r '.entries['$service'].svcname' /tmp/services.json)
uuid=$(/usr/bin/jq -c -r '.entries['$service'].uuid' /tmp/services.json)
network=$(/usr/bin/jq -c -r '.entries['$service'].network' /tmp/services.json)
multiplex=$(/usr/bin/jq -c -r '.entries['$service'].multiplex' /tmp/services.json)
desc="$network/$multiplex/$svcname"
echo \#EXTINF:-1, $desc | tee -a $date_time$file_name
echo http://$user_pass@$host/stream/service/$uuid\?profile=$profile | tee -a $date_time$file_name
fi
done
rm /tmp/services_unsorted.json /tmp/services.json
```
***