diff options
Diffstat (limited to 'iptv.sh')
| -rwxr-xr-x | iptv.sh | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -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[@]}" \ |
