summaryrefslogtreecommitdiff
path: root/iptv.sh
diff options
context:
space:
mode:
authorZhineng Li <[email protected]>2026-01-24 13:18:57 +0800
committerZhineng Li <[email protected]>2026-01-24 13:18:57 +0800
commite4108b605da47804d9b44d6c729046051165bb67 (patch)
treed3902bf6f18d26aab68ae92ea1989f57c4508029 /iptv.sh
parent2940d607ba8f2882a62f4e6754e9091154403eca (diff)
downloadchina-unicom-iptv-gd-e4108b605da47804d9b44d6c729046051165bb67.tar.gz
china-unicom-iptv-gd-e4108b605da47804d9b44d6c729046051165bb67.zip
extract `extract_endpoint` function
Diffstat (limited to 'iptv.sh')
-rwxr-xr-xiptv.sh27
1 files changed, 20 insertions, 7 deletions
diff --git a/iptv.sh b/iptv.sh
index 832f1fb..ad2dd04 100755
--- a/iptv.sh
+++ b/iptv.sh
@@ -80,6 +80,24 @@ categorize_by_channel_name () {
echo "$result"
}
+retrieve_endpoint () {
+ local user_id="$1"
+ local url="http://eds1.unicomgd.com:8082/EDS/jsp/AuthenticationURL?Action=Login&UserID=$user_id&return_type=1"
+ local response
+ local epgurl
+ response=$(curl "${CURL_ARGS[@]}" "$url") || return 1
+ epgurl=$(printf '%s' "$response" | jq -r '.epgurl')
+ printf '%s\n' "$(extract_hostname "$epgurl")"
+}
+
+extract_hostname () {
+ local url="$1"
+ local res
+ res="${url#*//}"
+ res="${res%%/*}"
+ printf '%s\n' "$res"
+}
+
build_authinfo () {
local encry_token="$1"
local user_id="$2"
@@ -182,7 +200,6 @@ make_playlist () {
local ip_address='127.0.0.1'
local udpxy_endpoint='http://127.0.0.1:4022'
local output_file='playlist.M3U8'
- local endpoint='http://eds1.unicomgd.com:8082'
while [ $# -gt 0 ]; do
case "$1" in
@@ -219,12 +236,8 @@ make_playlist () {
# Retreive Authentication URL
step "Authenticate"
- response=$(curl "${CURL_ARGS[@]}" \
- "$endpoint/EDS/jsp/AuthenticationURL?Action=Login&UserID=$user_id&return_type=1")
-
- epgurl=$(echo "$response" | jq -r '.epgurl')
- host="${epgurl#*//}"
- host="${host%%/*}"
+ local host
+ host=$(retrieve_endpoint "$user_id") || fatal 'Failed to retrieve endpoint'
# Retreive challenge token
response=$(curl "${CURL_ARGS[@]}" \