diff options
| author | Zhineng Li <[email protected]> | 2026-01-24 10:57:46 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-24 10:57:46 +0800 |
| commit | cfa2920000daffda5a056337e3ab662d67ad3f39 (patch) | |
| tree | 570fdec0d9d6b9d5744cf7fd433af4e0a3d8d9a5 /iptv.sh | |
| parent | 88120b1eb0266012f3c45ffc3c8218c8bdc972d5 (diff) | |
| download | china-unicom-iptv-gd-cfa2920000daffda5a056337e3ab662d67ad3f39.tar.gz china-unicom-iptv-gd-cfa2920000daffda5a056337e3ab662d67ad3f39.zip | |
extract authinfo functions
Diffstat (limited to 'iptv.sh')
| -rwxr-xr-x | iptv.sh | 42 |
1 files changed, 29 insertions, 13 deletions
@@ -72,6 +72,30 @@ categorize_by_channel_name () { echo "$result" } +build_authinfo () { + local encry_token="$1" + local user_id="$2" + local device_id="$3" + local ip_address="$4" + local mac_address="$5" + + local random_num=$(( (RANDOM << 15 | RANDOM) % 99999999 + 1 )) + local parts=("$random_num" "$encry_token" "$user_id" "$device_id" "$ip_address" "$mac_address" "Reserved" "OTT") + local joined + joined=$(IFS='$'; printf '%s' "${parts[*]}") + + printf '%s\n' "$joined" +} + +encrypt_authinfo () { + local data="$1" + local key="$2" + local res + res=$(printf '%s' "$data" | openssl enc -e -des-ede3 -K "$key" -nosalt 2>/dev/null | xxd -p -u -c 0) + + printf '%s\n' "$res" +} + make_epg () { # Check dependencies ensure_curl_is_installed @@ -203,20 +227,12 @@ make_playlist () { encry_token=$(echo "$response" | jq -r '.EncryToken') # Authenticate - pass=$(printf "%-024s" "$password" | tr ' ' 0 | xxd -p) - - authinfo=( - $(shuf -i 1-99999999 -n 1) $encry_token - $user_id $device_id - $ip_address $mac_address - "Reserved" "OTT" - ) - - authinfo=$(IFS='$'; echo "${authinfo[*]}") + local key + key=$(printf "%-24s" "$password" | tr ' ' 0 | xxd -p) - authinfo=$(echo -n $authinfo | \ - openssl enc -e -des-ede3 -K $pass -nosalt 2>/dev/null | \ - xxd -p -u -c 0) + local authinfo + 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 --silent $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=") |
