diff options
| author | Zhineng Li <[email protected]> | 2026-01-24 13:53:22 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-24 13:53:22 +0800 |
| commit | e37cf810b7a76ef0632db665d6dbf2646487ea5f (patch) | |
| tree | a7a4bdc4ba465fd6f4316819b66e8eaece1d6b55 | |
| parent | edd1d8a333dedbbae7b18aaa9fadc00765d9e498 (diff) | |
| download | china-unicom-iptv-gd-e37cf810b7a76ef0632db665d6dbf2646487ea5f.tar.gz china-unicom-iptv-gd-e37cf810b7a76ef0632db665d6dbf2646487ea5f.zip | |
| -rwxr-xr-x | iptv.sh | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -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[@]}" \ |
