Skip to content

Commit

Permalink
构建 增加APPX重试请求机制
Browse files Browse the repository at this point in the history
  • Loading branch information
xrgzs committed Aug 8, 2024
1 parent 3794fd1 commit 9d26047
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions osc/runtime/getappx.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
function Download-Appx($Name) {
Write-Host "Downloading $Name"
$obj = Invoke-WebRequest -Uri "https://store.xr6.xyz/api/GetFiles" `
-Method "POST" `
-ContentType "application/x-www-form-urlencoded" `
-Body @{
$body = @{
type = 'PackageFamilyName'
url = $Name + '_8wekyb3d8bbwe'
ring = 'RP'
lang = 'zh-CN'
}

while ($true) {
try {
$obj = Invoke-WebRequest -Uri "https://store.xr6.xyz/api/GetFiles" `
-Method "POST" `
-ContentType "application/x-www-form-urlencoded" `
-Body $body
break
}
catch {
Write-Host "请求失败,正在进行重试..."
Start-Sleep -Seconds 3
}
}
foreach ($link in $obj.Links) {
if ($link.outerHTML -match '(?<=<a\b[^>]*>).*?(?=</a>)') {
$linkText = $Matches[0]
Expand All @@ -18,6 +27,7 @@ function Download-Appx($Name) {
if (Test-Path -Path $linkText) {
Write-Warning "Already exists, skiping $linkText"
} else {
Write-Host "== $linkText ($($link.href))"
Invoke-WebRequest -Uri $link.href -OutFile "$PSScriptRoot\Extension\$linkText"
}
}
Expand Down

0 comments on commit 9d26047

Please sign in to comment.