diff --git a/src/mido.sh b/src/mido.sh
index d739553..a6a444b 100644
--- a/src/mido.sh
+++ b/src/mido.sh
@@ -57,36 +57,71 @@ get_agent() {
return 0
}
+convert_language() {
+
+ local lang=""
+
+ case "${1,,}" in
+ "gb" | "en-gb" )
+ lang="English International" ;;
+ "en" | "en-"* )
+ lang="English" ;;
+ "mx" | "es-mx" )
+ lang="Spanish (Mexico)" ;;
+ "ca" | "fr-ca" )
+ lang="French Canadian" ;;
+ "br" | "pt-br" )
+ lang="Brazilian Portuguese" ;;
+ "sr" | "sr-"* )
+ lang="Serbian Latin" ;;
+ "hk" | "zh-hk" | "cn-hk" )
+ lang="Chinese (Traditional)" ;;
+ "tw" | "zh-tw" | "cn-tw" )
+ lang="Chinese (Traditional)" ;;
+ "zh" | "zh-"* | "cn" | "cn-"* )
+ lang="Chinese (Simplified)" ;;
+ * )
+ lang=$(getLanguage "$1" "name") ;;
+ esac
+
+
+ echo "$lang"
+ return 0
+}
+
download_windows() {
local id="$1"
local lang="$2"
local desc="$3"
local sku_id=""
+ local sku_url=""
+ local iso_url=""
+ local iso_json=""
local language=""
local session_id=""
local user_agent=""
+ local download_type=""
local windows_version=""
local iso_download_link=""
+ local download_page_html=""
local product_edition_id=""
- local iso_download_link_html=""
- local iso_download_page_html=""
- local language_skuid_table_html=""
+ local language_skuid_json=""
+ local profile="606624d44113"
+
+ user_agent=$(get_agent)
+ language=$(convert_language "$lang")
+ [ -z "$language" ] && error "Invalid language: $lang" && return 1
case "${id,,}" in
- "win11x64" ) windows_version="11" ;;
- "win10x64" ) windows_version="10" ;;
- "win81x64" ) windows_version="8" ;;
+ "win11x64" ) windows_version="11" && download_type="1" ;;
+ "win10x64" ) windows_version="10" && download_type="1" ;;
+ "win11arm64" ) windows_version="11arm64" && download_type="2" ;;
* ) error "Invalid VERSION specified, value \"$id\" is not recognized!" && return 1 ;;
esac
- user_agent=$(get_agent)
- language=$(getLanguage "$lang" "name")
-
local url="https://www.microsoft.com/en-us/software-download/windows$windows_version"
- case "$windows_version" in
- 8 | 10) url+="ISO";;
- esac
+ [[ "${id,,}" == "win10"* ]] && url+="ISO"
# uuidgen: For MacOS (installed by default) and other systems (e.g. with no /proc) that don't have a kernel interface for generating random UUIDs
session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
@@ -96,44 +131,40 @@ download_windows() {
# This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically
# Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden
# Remove "Accept" header that curl sends by default
- [[ "$DEBUG" == [Yy1]* ]] && echo " - Parsing download page: ${url}"
- iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
+ [[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
+ download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
handle_curl_error $?
return $?
}
[[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: "
- # tr: Filter for only numerics to prevent HTTP parameter injection
- # head -c was recently added to POSIX: https://austingroupbugs.net/view.php?id=407
- product_edition_id=$(echo "$iso_download_page_html" | grep -Eo '