summaryrefslogtreecommitdiff
path: root/iptv.sh
diff options
context:
space:
mode:
Diffstat (limited to 'iptv.sh')
-rwxr-xr-xiptv.sh19
1 files changed, 15 insertions, 4 deletions
diff --git a/iptv.sh b/iptv.sh
index aa9fd55..b06cdc4 100755
--- a/iptv.sh
+++ b/iptv.sh
@@ -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