***
```
#!/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 &
#39;+%d-%B-%Y_%H-%M&
#39;`
# Для работы с 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 &
#39;.entries |= sort_by(.network, .multiplex, .svcname)&
#39; /tmp/services_unsorted.json > /tmp/services.json
echo \
#EXTM3U | tee -a # tee выводит данные из потока ввода в поток вывода и дублирует эти данные в указанные файлы
# tee -a дописать в заданные ФАЙЛЫ
entries=$(/usr/bin/jq -c &
#39;.total&
#39; /tmp/services.json)
for (( service=0; service<= $entries; service++ ))
do
enabled=$(/usr/bin/jq -c &
#39;.entries[&
#39;$service&
#39;].enabled&
#39; /tmp/services.json)
if [ "$enabled" = "true" ]
then
svcname=$(/usr/bin/jq -c -r &
#39;.entries[&
#39;$service&
#39;].svcname&
#39; /tmp/services.json)
uuid=$(/usr/bin/jq -c -r &
#39;.entries[&
#39;$service&
#39;].uuid&
#39; /tmp/services.json)
network=$(/usr/bin/jq -c -r &
#39;.entries[&
#39;$service&
#39;].network&
#39; /tmp/services.json)
multiplex=$(/usr/bin/jq -c -r &
#39;.entries[&
#39;$service&
#39;].multiplex&
#39; /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
```
***