summaryrefslogtreecommitdiff
path: root/iptv.sh
diff options
context:
space:
mode:
Diffstat (limited to 'iptv.sh')
-rwxr-xr-xiptv.sh36
1 files changed, 24 insertions, 12 deletions
diff --git a/iptv.sh b/iptv.sh
index b692d11..400bed3 100755
--- a/iptv.sh
+++ b/iptv.sh
@@ -147,6 +147,27 @@ retrieve_access_token () {
printf '%s\n' "$token"
}
+build_channel_logos () {
+ local -n ref=$1
+ [[ -n "$1" ]] || return 1
+
+ local url='http://120.87.12.38:8083/epg/api/custom/getAllChannel.json'
+ local response
+ response=$(curl "${CURL_ARGS[@]}" "$url") || return 1
+ [[ -n "$response" ]] || return 1
+
+ local channel
+ local hwcode
+ local icon
+ while read -r channel; do
+ hwcode=$(printf '%s' "$channel" | jq -r '.params.hwcode') || return 1
+ icon=$(printf '%s' "$channel" | jq -r '.icon') || return 1
+ [[ -n "$hwcode" && "$hwcode" != "null" ]] || continue
+ [[ -n "$icon" && "$icon" != "null" ]] || continue
+ ref["$hwcode"]="$icon"
+ done < <(printf '%s' "$response" | jq -c '.channels[]') || return 1
+}
+
make_epg () {
# Check dependencies
ensure_curl_is_installed
@@ -276,18 +297,9 @@ make_playlist () {
local access_token
access_token=$(retrieve_access_token "$host" "$user_id" "$authinfo") || fatal 'Failed to retrieve access token'
- step "Request channel metas"
- declare -A logos
-
- response=$(curl "${CURL_ARGS[@]}" \
- http://120.87.12.38:8083/epg/api/custom/getAllChannel.json)
-
- while read -r channel; do
- hwcode=$(echo "$channel" | jq -r '.params.hwcode')
- icon=$(echo "$channel" | jq -r '.icon')
-
- logos["$hwcode"]="$icon"
- done < <(echo "$response" | jq -c '.channels[]')
+ step "Request channel logos"
+ local -A logos
+ build_channel_logos logos
step "Request channels from the batch API"
response=$(curl "${CURL_ARGS[@]}" \