Created
July 5, 2021 05:28
-
-
Save ohaiibuzzle/6c0d09b7cc3572342f90c151833649b6 to your computer and use it in GitHub Desktop.
Download Genshin without the launcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[switch]$en = $true, | |
[switch]$jp = $false, | |
[switch]$ko = $false, | |
[switch]$cn = $false, | |
[switch]$extract = $false | |
) | |
Add-Type -Assembly System.Windows.Forms | |
function Get-Aria2{ | |
Invoke-WebRequest -Uri https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0-win-64bit-build1.zip -OutFile 'aria.zip' | |
if ((Get-FileHash -Algorithm MD5 'aria.zip' | Select-Object Hash).Hash -ne '118D109C350993E6A8B43CBC3700E0A7') { | |
Write-Host "Hash for aria2 does not match. It is possible someone has done something nasty!" | |
Remove-Item 'aria.zip' | |
exit | |
} | |
Add-Type -Assembly System.IO.Compression.FileSystem | |
$zip = [IO.Compression.ZipFile]::OpenRead('aria.zip') | |
$zip.Entries | where {$_.Name -like 'aria2c.exe'} | foreach {[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, "aria2c.exe", $true)} | |
$zip.Dispose() | |
Remove-Item 'aria.zip' | |
} | |
function Get-7zip{ | |
Invoke-WebRequest -Uri 'https://download.sourceforge.net/sevenzip/7za920.zip' -OutFile '7z.zip' | |
if ((Get-FileHash -Algorithm MD5 '7z.zip' | Select-Object Hash).Hash -ne '2FAC454A90AE96021F4FFC607D4C00F8') { | |
Write-Host "Hash for 7zip does not match. It is possible someone has done something nasty!" | |
Remove-Item '7z.zip' | |
exit | |
} | |
Add-Type -Assembly System.IO.Compression.FileSystem | |
$zip = [IO.Compression.ZipFile]::OpenRead('7z.zip') | |
$zip.Entries | where {$_.Name -like '7za.exe'} | foreach {[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, "7za.exe", $true)} | |
$zip.Dispose() | |
} | |
function Invoke-AriaDownload{ | |
param ( | |
$Uri, | |
$MD5hash | |
) | |
if (-not(Test-Path '.\aria2c.exe')){Get-Aria2} | |
$Parms = "-UWget -x16 -j16 -s16 -k 1M -Vtrue --checksum=md5=$MD5hash $Uri" | |
$Prms = $Parms.Split() | |
& ".\aria2c.exe" $Prms | |
} | |
function Invoke-7zExtraction{ | |
param( | |
$FileName | |
) | |
if (-not(Test-Path '.\7za.exe')){Get-Aria2} | |
$Parms = "x $FileName" | |
$Prms = $Parms.Split() | |
& ".\7za.exe" $Prms | |
} | |
function Get-GameFiles{ | |
$target = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/resource?launcher_id=10&key=gcStgarh' | |
$info = Invoke-WebRequest -Uri $target | ConvertFrom-Json | |
Write-Host "Downloading version $($info.data.game.latest.version)" | |
Invoke-AriaDownload -Uri $info.data.game.latest.path -MD5hash $info.data.game.latest.md5 | |
foreach ($pack in $info.data.game.latest.voice_packs){ | |
if (($pack.language -eq 'en-us') -and ($en)){ | |
Invoke-AriaDownload -Uri $pack.path -MD5hash $pack.md5 | |
} | |
if (($pack.language -eq 'ja-jp') -and ($ja)){ | |
Invoke-AriaDownload -Uri $pack.path -MD5hash $pack.md5 | |
} | |
if (($pack.language -eq 'zh-cn') -and ($ko)){ | |
Invoke-AriaDownload -Uri $pack.path -MD5hash $pack.md5 | |
} | |
if (($pack.language -eq 'ko-kr') -and ($cn)){ | |
Invoke-AriaDownload -Uri $pack.path -MD5hash $pack.md5 | |
} | |
} | |
} | |
function Extract-AllGameFiles{ | |
Get-ChildItem -File -Filter *.zip | ForEach-Object {Invoke-7zExtraction -FileName $_} | |
} | |
Write-Host("Select your install folder...") | |
$FileBrowser = New-Object System.Windows.Forms.FolderBrowserDialog | |
$FileBrowser.Description = "Select your install folder" | |
if($FileBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true })) -eq "OK"){ | |
Set-Location($FileBrowser.SelectedPath) | |
} else { | |
exit | |
} | |
Write-Host("Warning: You are about to download 13+ GB of data. Make sure you aren't going to go bankrupt!") | |
Pause | |
Get-GameFiles | |
if ($extract) { | |
Invoke-7zExtraction | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment