diff options
| author | Zhineng Li <[email protected]> | 2026-01-24 13:29:59 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-24 13:29:59 +0800 |
| commit | ddab55b91d9af60011ceddca3cc589f4027caf01 (patch) | |
| tree | 104824af4d31f3f729167154a344e892f611fe7e | |
| parent | e4108b605da47804d9b44d6c729046051165bb67 (diff) | |
| download | china-unicom-iptv-gd-ddab55b91d9af60011ceddca3cc589f4027caf01.tar.gz china-unicom-iptv-gd-ddab55b91d9af60011ceddca3cc589f4027caf01.zip | |
extract `retrieve_encry_token` function
| -rwxr-xr-x | iptv.sh | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -98,6 +98,18 @@ extract_hostname () { printf '%s\n' "$res" } +retrieve_encry_token () { + local endpoint="$1" + local user_id="$2" + local url="http://$endpoint/EPG/oauth/v2/authorize?response_type=EncryToken&client_id=jiulian&userid=$user_id" + local response + local token + response=$(curl "${CURL_ARGS[@]}" "$url") || return 1 + token=$(printf '%s' "$response" | jq -r '.EncryToken') || return 1 + [[ -n "$token" && "$token" != "null" ]] || return 1 + printf '%s\n' "$token" +} + build_authinfo () { local encry_token="$1" local user_id="$2" @@ -239,11 +251,8 @@ make_playlist () { local host host=$(retrieve_endpoint "$user_id") || fatal 'Failed to retrieve endpoint' - # Retreive challenge token - response=$(curl "${CURL_ARGS[@]}" \ - "http://$host/EPG/oauth/v2/authorize?response_type=EncryToken&client_id=jiulian&userid=$user_id") - - encry_token=$(echo "$response" | jq -r '.EncryToken') + local encry_token + encry_token=$(retrieve_encry_token "$host" "$user_id") || fatal 'Failed to retrieve encry token' # Authenticate local key |
