diff options
| author | Zhineng Li <[email protected]> | 2026-01-24 13:39:29 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-24 13:39:29 +0800 |
| commit | fa1fe75f772f1bb105e281a9986087642df3460a (patch) | |
| tree | 51920c7d159c1676fc4156d2f776e09c67b7d683 /iptv.sh | |
| parent | ddab55b91d9af60011ceddca3cc589f4027caf01 (diff) | |
| download | china-unicom-iptv-gd-fa1fe75f772f1bb105e281a9986087642df3460a.tar.gz china-unicom-iptv-gd-fa1fe75f772f1bb105e281a9986087642df3460a.zip | |
extract `retrieve_access_token` function
Diffstat (limited to 'iptv.sh')
| -rwxr-xr-x | iptv.sh | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -134,6 +134,19 @@ encrypt_authinfo () { printf '%s\n' "$res" } +retrieve_access_token () { + local endpoint="$1" + local user_id="$2" + local authinfo="$3" + local url="http://$endpoint/EPG/oauth/v2/token?grant_type=EncryToken&client_id=jiulian&UserID=$user_id&DeviceType=UNT400G&DeviceVersion=5.5.021&authinfo=$authinfo&issmarthomestb=1&tvdesktopid=" + local response + local token + response=$(curl "${CURL_ARGS[@]}" "$url") || return 1 + token=$(printf '%s' "$response" | jq -r '.access_token') || return 1 + [[ -n "$token" && "$token" != "null" ]] || return 1 + printf '%s\n' "$token" +} + make_epg () { # Check dependencies ensure_curl_is_installed @@ -262,10 +275,8 @@ make_playlist () { authinfo=$(build_authinfo "$encry_token" "$user_id" "$device_id" "$ip_address" "$mac_address") || fatal 'Failed to build authinfo' authinfo=$(encrypt_authinfo "$authinfo" "$key") || fatal 'Failed to encrypt authinfo' - response=$(curl "${CURL_ARGS[@]}" \ - "http://$host/EPG/oauth/v2/token?grant_type=EncryToken&client_id=jiulian&UserID=$user_id&DeviceType=UNT400G&DeviceVersion=5.5.021&authinfo=$authinfo&issmarthomestb=1&tvdesktopid=") - - access_token=$(echo "$response" | jq -r '.access_token') + 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 |
