Skip to content

Commit

Permalink
Update Build.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 authored Jul 20, 2024
1 parent 8b1763c commit 040eb19
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,45 @@ $Parameters = @{
}
$LatestSupported = ((Invoke-RestMethod @Parameters).patches | Where-Object -FilterScript {$_.name -eq "Video ads"}).compatiblePackages.versions | Sort-Object -Descending -Unique | Select-Object -First 1

$LatestSupported = $LatestSupported.Replace(".", "-")

# We need a NON-bundle version
# https://apkpure.net/ru/youtube/com.google.android.youtube/versions
# https://www.apkmirror.com/apk/google-inc/youtube/
$Parameters = @{
Uri = "https://www.apkmirror.com/apk/google-inc/youtube/youtube-$($LatestSupported)-release/youtube-$($LatestSupported)-android-apk-download/"
UseBasicParsing = $false # Disabled
Verbose = $true
}
$Request = Invoke-Webrequest @Parameters

$Parameters = @{
Uri = "https://www.apkmirror.com/apk/google-inc/youtube/youtube-$($LatestSupported)-release/youtube-$($LatestSupported)-2-android-apk-download/"
UseBasicParsing = $false # Disabled
Verbose = $true
}
$Request2 = Invoke-Webrequest @Parameters

@($Request, $Request2) | ForEach-Object -Process {
$RequestVariable = $_

$RequestVariable.ParsedHtml.getElementsByTagName("a") | Where-Object -FilterScript {$_.className -match "downloadButton"} | ForEach-Object -Process {
if ($_.innerText -notmatch "Download APK Bundle")
{
$DownloadKey = $_.href.Replace("about:/", "")
}
}
}

$Parameters = @{
Uri = "https://apkpure.net/youtube/com.google.android.youtube/download/$($LatestSupported)"
Uri = "https://www.apkmirror.com/$DownloadKey"
UseBasicParsing = $true
Verbose = $true
}
$DownloadURL = (Invoke-Webrequest @Parameters).Links.href | Where-Object -FilterScript {$_ -match "APK/com.google.android.youtube"} | Select-Object -Index 1
$Request = Invoke-Webrequest @Parameters
$DownloadURL = $Request.Links.href | Where-Object -FilterScript {$_ -match "download.php"}

$Parameters = @{
Uri = $DownloadURL
Uri = "https://www.apkmirror.com/$DownloadURL"
OutFile = "$DownloadsFolder\ReVanced\youtube.apk"
UseBasicParsing = $true
Verbose = $true
Expand Down

0 comments on commit 040eb19

Please sign in to comment.