This commit is contained in:
CoolnsX
2022-07-15 14:38:34 +05:30
parent 3f5c09d709
commit 1ced6fc23c

22
hls
View File

@@ -39,16 +39,20 @@ trap "rm -rdf $tmpdir $jobdir;exit 0" INT HUP
printf "\033[2K\r\033[1;36mFetching resolutions.." printf "\033[2K\r\033[1;36mFetching resolutions.."
m3u8_data=$(curl -s "$link") m3u8_data=$(curl -s "$link")
res_list=$(printf "%s" "$m3u8_data" | sed -nE 's_.*RESOLUTION=.*x([^,]*),.*_\1_p') res_list=$(printf "%s" "$m3u8_data" | sed -nE 's_.*RESOLUTION=.*x([^,]*),.*_\1_p')
highest_res=$(printf "$res_list" | sort -nr | head -1) if [ -n "$res_list" ];then
[ "$skip_res" -eq 1 ] && printf "\033[2K\r\033[1;36mSelecting highest resolution.." || (printf "" printf "\033[2K\r\033[1;33mRESOLUTIONS >>\n\033[0m$res_list\n\033[1;34mType ur preferred resolution (default: $highest_res) > " && read -r sel_res) highest_res=$(printf "$res_list" | sort -nr | head -1)
[ -z "$sel_res" ] && sel_res=$highest_res [ "$skip_res" -eq 1 ] && printf "\033[2K\r\033[1;36mSelecting highest resolution.." || (printf "\033[2K\r\033[1;33mRESOLUTIONS >>\n\033[0m$res_list\n\033[1;34mType ur preferred resolution (default: $highest_res) > " && read -r sel_res)
unset highest_res res_list [ -z "$sel_res" ] && sel_res=$highest_res
url=$(printf "%s" "$m3u8_data" | sed -n "/$sel_res,/{n;p;}" | tr -d '\r') unset highest_res res_list
[ -d "$tmpdir" ] || mkdir -p "$tmpdir" url=$(printf "%s" "$m3u8_data" | sed -n "/$sel_res,/{n;p;}" | tr -d '\r')
#check whether the m3u8_data contains uri that starts from http #check whether the m3u8_data contains uri that starts from http
printf "%s" "$m3u8_data" | grep -q "http" || relative_url=$(printf "%s" "$link" | sed 's_[^/]*$__') printf "%s" "$m3u8_data" | grep -q "http" || relative_url=$(printf "%s" "$link" | sed 's_[^/]*$__')
printf "\033[2K\r\033[1;36mFetching Metadata.." printf "\033[2K\r\033[1;36mFetching Metadata.."
resp="$(curl -s "${relative_url}$url")" resp="$(curl -s "${relative_url}$url")"
else
resp=$m3u8_data
fi
[ -d "$tmpdir" ] || mkdir -p "$tmpdir"
#extract key uri and iv uri from encrypted stream if exists.. #extract key uri and iv uri from encrypted stream if exists..
key_uri="$(printf "%s" "$resp" | sed -nE 's/^#EXT-X-KEY.*URI="([^"]*)"/\1/p')" key_uri="$(printf "%s" "$resp" | sed -nE 's/^#EXT-X-KEY.*URI="([^"]*)"/\1/p')"
[ -z "$key_uri" ] || iv_uri="$(printf "%s" "$resp" | sed -nE 's/^#EXT-X-IV.*URI="([^"]*)"/\1/p')" [ -z "$key_uri" ] || iv_uri="$(printf "%s" "$resp" | sed -nE 's/^#EXT-X-IV.*URI="([^"]*)"/\1/p')"