Get WSA download link directly from MS API (#481)
This commit is contained in:
96
.github/workflows/magisk.yml
vendored
96
.github/workflows/magisk.yml
vendored
@@ -98,53 +98,95 @@ jobs:
|
||||
steps:
|
||||
- name: Dependencies
|
||||
run: |
|
||||
pip3 install beautifulsoup4 lxml
|
||||
sudo apt-get update && sudo apt-get install setools lzip wine winetricks patchelf
|
||||
wget -qO- "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$GITHUB_REF.tar.gz" | sudo tar --wildcards -zxvf- -C ~ --strip-component=2 '*/wine/*' '*/linker/*'
|
||||
wget -qO- "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$GITHUB_REF.tar.gz" | sudo tar --wildcards -zxvf- -C ~ --strip-component=2 '*/wine/*' '*/linker/*' '*/xml/*'
|
||||
winetricks msxml6
|
||||
echo "163.172.251.201 store.rg-adguard.net" | sudo tee -a /etc/hosts
|
||||
- name: Download WSA
|
||||
shell: python
|
||||
run: |
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from xml.dom import minidom
|
||||
import html
|
||||
import warnings
|
||||
import re
|
||||
import zipfile
|
||||
import os
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
arch = "${{ matrix.arch }}"
|
||||
release_type_map = {"retail": "Retail", "release preview": "RP", "insider slow": "WIS", "insider fast": "WIF"}
|
||||
release_type = release_type_map["${{ github.event.inputs.release_type }}"] if "${{ github.event.inputs.release_type }}" != "" else "Retail"
|
||||
|
||||
res = requests.post("https://store.rg-adguard.net/api/GetFiles", f"type=CategoryId&url=858014f3-3934-4abe-8078-4aa193e74ca8&ring={release_type}&lang=en-US", headers={
|
||||
"content-type": "application/x-www-form-urlencoded"
|
||||
}, verify=False) # source site has expired cert
|
||||
html = BeautifulSoup(res.content, "lxml")
|
||||
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
|
||||
|
||||
a = html.find("a", string=re.compile(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx"))
|
||||
link = a["href"]
|
||||
print(f"downloading link: {link}", flush=True)
|
||||
out_file = "xaml.appx"
|
||||
if not os.path.isfile(out_file):
|
||||
urllib.request.urlretrieve(link, out_file)
|
||||
with open(Path.home() / "GetCookie.xml", "r") as f:
|
||||
cookie_content = f.read()
|
||||
|
||||
a = html.find("a", string=re.compile(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx"))
|
||||
link = a["href"]
|
||||
print(f"downloading link: {link}", flush=True)
|
||||
out_file = "vclibs.appx"
|
||||
if not os.path.isfile(out_file):
|
||||
urllib.request.urlretrieve(link, out_file)
|
||||
out = requests.post(
|
||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
||||
data=cookie_content,
|
||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||
verify=False
|
||||
)
|
||||
doc = minidom.parseString(out.text)
|
||||
cookie = doc.getElementsByTagName('EncryptedData')[0].firstChild.nodeValue
|
||||
|
||||
a = html.find("a", string=re.compile("MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle"))
|
||||
link = a["href"]
|
||||
print(f"downloading link: {link}", flush=True)
|
||||
out_file = "wsa.zip"
|
||||
if not os.path.isfile(out_file):
|
||||
urllib.request.urlretrieve(link, out_file)
|
||||
print(cookie)
|
||||
|
||||
with open(Path.home() / "WUIDRequest.xml", "r") as f:
|
||||
cat_id_content = f.read().format(cookie, cat_id, release_type)
|
||||
|
||||
out = requests.post(
|
||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
||||
data=cat_id_content,
|
||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||
verify=False
|
||||
)
|
||||
|
||||
doc = minidom.parseString(html.unescape(out.text))
|
||||
|
||||
filenames = {}
|
||||
for node in doc.getElementsByTagName('Files'):
|
||||
filenames[node.parentNode.parentNode.getElementsByTagName('ID')[0].firstChild.nodeValue] = f"{node.firstChild.attributes['InstallerSpecificIdentifier'].value}_{node.firstChild.attributes['FileName'].value}"
|
||||
pass
|
||||
|
||||
identities = []
|
||||
for node in doc.getElementsByTagName('SecuredFragment'):
|
||||
filename = filenames[node.parentNode.parentNode.parentNode.getElementsByTagName('ID')[0].firstChild.nodeValue]
|
||||
update_identity = node.parentNode.parentNode.firstChild
|
||||
identities += [(update_identity.attributes['UpdateID'].value, update_identity.attributes['RevisionNumber'].value, filename)]
|
||||
|
||||
with open(Path.home() / "FE3FileUrl.xml", "r") as f:
|
||||
file_content = f.read()
|
||||
|
||||
for i, v, f in identities:
|
||||
if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f):
|
||||
out_file = "xaml.appx"
|
||||
elif re.match(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx", f):
|
||||
out_file = "vclibs.appx"
|
||||
elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", f):
|
||||
out_file = "wsa.zip"
|
||||
else:
|
||||
continue
|
||||
out = requests.post(
|
||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured',
|
||||
data=file_content.format(i, v),
|
||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||
verify=False
|
||||
)
|
||||
doc = minidom.parseString(out.text)
|
||||
for l in doc.getElementsByTagName("FileLocation"):
|
||||
url = l.getElementsByTagName("Url")[0].firstChild.nodeValue
|
||||
if len(url) != 99:
|
||||
if not os.path.isfile(out_file):
|
||||
print(f"downloading link: {url} to {out_file}", flush=True)
|
||||
urllib.request.urlretrieve(url, out_file)
|
||||
|
||||
zip_name = ""
|
||||
with zipfile.ZipFile(out_file) as zip:
|
||||
with zipfile.ZipFile("wsa.zip") as zip:
|
||||
for f in zip.filelist:
|
||||
if arch in f.filename.lower():
|
||||
zip_name = f.filename
|
||||
|
Reference in New Issue
Block a user