mirror of
https://github.com/JDM170/ReVanced_Builder
synced 2025-11-29 14:41:46 +07:00
Compare commits
11 Commits
2024.05.01
...
2025.11.01
| Author | SHA1 | Date | |
|---|---|---|---|
|
4c356736b0
|
|||
|
ca508c0e24
|
|||
|
b879ad95f3
|
|||
|
3edfdcc627
|
|||
| d2ab1f83d7 | |||
| 689cf90f6a | |||
|
9c38444051
|
|||
|
65dc96ac52
|
|||
|
4905811659
|
|||
|
4758eb22cf
|
|||
|
c3c0a74bfe
|
25
.github/workflows/Build.yml
vendored
25
.github/workflows/Build.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 3 1 * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -10,6 +12,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
|
||||
- name: Install AngleSharp
|
||||
run: |
|
||||
Install-Package AngleSharp -Source https://www.nuget.org/api/v2 -SkipDependencies -Force
|
||||
|
||||
- name: Download YouTube
|
||||
run: |
|
||||
New-Item -Path Temp -ItemType Directory -Force
|
||||
@@ -24,10 +30,6 @@ jobs:
|
||||
run: |
|
||||
. Scripts\ReVanced_Patches.ps1
|
||||
|
||||
- name: Download ReVanced Integrations
|
||||
run: |
|
||||
. Scripts\ReVanced_Intergrations.ps1
|
||||
|
||||
- name: Download Vanced MicroG
|
||||
run: |
|
||||
. Scripts\MicroG.ps1
|
||||
@@ -42,12 +44,11 @@ jobs:
|
||||
|
||||
& $JavaPath `
|
||||
-jar "Temp\revanced-cli.jar" patch `
|
||||
--patch-bundle "Temp\revanced-patches.jar" `
|
||||
--merge "Temp\revanced-integrations.apk" `
|
||||
--exclude "Always repeat" `
|
||||
--exclude "Hide captions button" `
|
||||
--exclude "Hide timestamp" `
|
||||
--exclude "Hide seekbar" `
|
||||
--patches "Temp\revanced-patches.rvp" `
|
||||
--disable "Always repeat" `
|
||||
--disable "Disable auto captions" `
|
||||
--disable "Hide timestamp" `
|
||||
--disable "Hide seekbar" `
|
||||
--purge `
|
||||
--out "Temp\revanced.apk" `
|
||||
"Temp\youtube.apk"
|
||||
@@ -67,14 +68,14 @@ jobs:
|
||||
id: read_release
|
||||
run: |
|
||||
# https://en.wikipedia.org/wiki/Percent-encoding
|
||||
(Get-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Raw).replace("YouTubeTag", "${{ env.LatestSupportedYT }}").replace("CLITag", "${{ env.CLIvtag }}").replace("PatchesTag", "${{ env.Patchesvtag }}").replace("IntegrationsTag", "${{ env.IntegrationsTag }}").replace("MicroGTag", "${{ env.MicroGTag }}").replace("ZuluTag", "${{ env.ZuluTag }}") | Set-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Force
|
||||
(Get-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Raw).replace("YouTubeTag", "${{ env.LatestSupportedYT }}").replace("CLITag", "${{ env.CLIvtag }}").replace("PatchesTag", "${{ env.Patchesvtag }}").replace("MicroGTag", "${{ env.MicroGTag }}").replace("ZuluTag", "${{ env.ZuluTag }}") | Set-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Force
|
||||
# https://trstringer.com/github-actions-multiline-strings/
|
||||
Add-Content -Path $env:GITHUB_OUTPUT -Value "ReleaseBody=ReleaseNotesTemplate.md"
|
||||
$ReleaseName = Get-Date -f "yyyy.MM.dd"
|
||||
echo "RELEASE_NAME=$ReleaseName" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Upload to Releases
|
||||
uses: softprops/action-gh-release@master
|
||||
uses: softprops/action-gh-release@v2.2.1
|
||||
with:
|
||||
tag_name: ${{ env.RELEASE_NAME }}
|
||||
body_path: ${{ steps.read_release.outputs.ReleaseBody }}
|
||||
|
||||
149
Build.ps1
149
Build.ps1
@@ -28,23 +28,27 @@ if ($Host.Version.Major -eq 5)
|
||||
}
|
||||
|
||||
# Download all files to "Script location folder\ReVanced"
|
||||
$WorkingFolder = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
if (-not (Test-Path -Path "$WorkingFolder\ReVanced"))
|
||||
$CurrentFolder = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
if (-not (Test-Path -Path "$CurrentFolder\ReVanced"))
|
||||
{
|
||||
New-Item -Path "$WorkingFolder\ReVanced" -ItemType Directory -Force
|
||||
New-Item -Path "$CurrentFolder\ReVanced" -ItemType Directory -Force
|
||||
}
|
||||
|
||||
# Get the latest supported YouTube version to patch
|
||||
# https://api.revanced.app/docs/swagger
|
||||
# https://api.revanced.app
|
||||
$Parameters = @{
|
||||
Uri = "https://api.revanced.app/v2/patches/latest"
|
||||
Uri = "https://api.revanced.app/v4/patches/list"
|
||||
UseBasicParsing = $true
|
||||
}
|
||||
$JSON = (Invoke-RestMethod @Parameters).patches
|
||||
$versions = ($JSON | Where-Object -FilterScript {$_.compatiblePackages.name -eq "com.google.android.youtube"}).compatiblePackages.versions
|
||||
$LatestSupported = $versions | Sort-Object -Descending -Unique | Select-Object -First 1
|
||||
$JSON = (Invoke-Webrequest @Parameters).Content | ConvertFrom-Json
|
||||
$versions = ($JSON | Where-Object -FilterScript {$_.name -eq "Video ads"})
|
||||
$LatestSupported = $versions.compatiblePackages.'com.google.android.youtube' | Sort-Object -Descending -Unique | Select-Object -First 1
|
||||
|
||||
Write-Verbose -Message "" -Verbose
|
||||
Write-Verbose -Message "Downloading the latest supported YouTube apk" -Verbose
|
||||
|
||||
# We need a NON-bundle version
|
||||
<#
|
||||
# https://apkpure.net/ru/youtube/com.google.android.youtube/versions
|
||||
$Parameters = @{
|
||||
Uri = "https://apkpure.net/youtube/com.google.android.youtube/download/$($LatestSupported)"
|
||||
@@ -55,12 +59,62 @@ $URL = (Invoke-Webrequest @Parameters).Links.href | Where-Object -FilterScript {
|
||||
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
OutFile = "$WorkingFolder\ReVanced\youtube.apk"
|
||||
OutFile = "$CurrentFolder\ReVanced\youtube.apk"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-Webrequest @Parameters
|
||||
#>
|
||||
|
||||
# https://www.apkmirror.com/apk/google-inc/youtube/
|
||||
$apkMirrorLink = "https://www.apkmirror.com/apk/google-inc/youtube/youtube-$($LatestSupported.replace('.', '-'))-release/"
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink
|
||||
UseBasicParsing = $false # Disabled
|
||||
Verbose = $true
|
||||
}
|
||||
$Request = Invoke-Webrequest @Parameters
|
||||
$Request.ParsedHtml.getElementsByClassName("table-row headerFont") | ForEach-Object -Process {
|
||||
foreach ($child in $_.children)
|
||||
{
|
||||
if ($child.innerText -eq "nodpi")
|
||||
{
|
||||
$apkPackageLink = ($_.getElementsByTagName("a") | Select-Object -First 1).nameProp
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
$apkMirrorLink += $apkPackageLink # actual APK link (not BUNDLE)
|
||||
|
||||
# Get unique key to generate direct link
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink
|
||||
UseBasicParsing = $false # Disabled
|
||||
Verbose = $true
|
||||
}
|
||||
$Request = Invoke-Webrequest @Parameters
|
||||
$nameProp = $Request.ParsedHtml.getElementsByClassName("accent_bg btn btn-flat downloadButton") | ForEach-Object -Process {$_.nameProp}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink + "/download/$($nameProp)"
|
||||
UseBasicParsing = $false # Disabled
|
||||
Verbose = $true
|
||||
}
|
||||
$URL_Part = ((Invoke-Webrequest @Parameters).Links | Where-Object -FilterScript {$_.innerHTML -eq "here"}).href
|
||||
# Replace "&" with "&" to make it work
|
||||
$URL_Part = $URL_Part.Replace("&", "&")
|
||||
|
||||
# Finally, get the real link
|
||||
$Parameters = @{
|
||||
Uri = "https://www.apkmirror.com$URL_Part"
|
||||
OutFile = "$CurrentFolder\ReVanced\youtube.apk"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-Webrequest @Parameters
|
||||
|
||||
Write-Verbose -Message "" -Verbose
|
||||
Write-Verbose -Message "Downloading ReVanced CLI" -Verbose
|
||||
# https://github.com/revanced/revanced-cli
|
||||
$Parameters = @{
|
||||
Uri = "https://api.github.com/repos/revanced/revanced-cli/releases/latest"
|
||||
@@ -70,42 +124,31 @@ $Parameters = @{
|
||||
$URL = ((Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.content_type -eq "application/java-archive"}).browser_download_url
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "$WorkingFolder\ReVanced\revanced-cli.jar"
|
||||
Outfile = "$CurrentFolder\ReVanced\revanced-cli.jar"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-RestMethod @Parameters
|
||||
|
||||
Write-Verbose -Message "" -Verbose
|
||||
Write-Verbose -Message "Downloading ReVanced patches" -Verbose
|
||||
# https://github.com/revanced/revanced-patches
|
||||
$Parameters = @{
|
||||
Uri = "https://api.github.com/repos/revanced/revanced-patches/releases/latest"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
$URL = ((Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.content_type -eq "application/java-archive"}).browser_download_url
|
||||
$URL = ((Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.content_type -eq "text/plain"}).browser_download_url
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "$WorkingFolder\ReVanced\revanced-patches.jar"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-RestMethod @Parameters
|
||||
|
||||
# https://github.com/revanced/revanced-integrations
|
||||
$Parameters = @{
|
||||
Uri = "https://api.github.com/repos/revanced/revanced-integrations/releases/latest"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
$URL = ((Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.content_type -eq "application/vnd.android.package-archive"}).browser_download_url
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "$WorkingFolder\ReVanced\revanced-integrations.apk"
|
||||
Outfile = "$CurrentFolder\ReVanced\revanced-patches.rvp"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-RestMethod @Parameters
|
||||
|
||||
Write-Verbose -Message "" -Verbose
|
||||
Write-Verbose -Message "Downloading ReVanced GmsCore" -Verbose
|
||||
# https://github.com/ReVanced/GmsCore
|
||||
$Parameters = @{
|
||||
Uri = "https://api.github.com/repos/ReVanced/GmsCore/releases/latest"
|
||||
@@ -121,7 +164,7 @@ foreach($url in $URL) {
|
||||
}
|
||||
$Parameters = @{
|
||||
Uri = $url.browser_download_url
|
||||
Outfile = "$WorkingFolder\ReVanced\$($url.name)"
|
||||
Outfile = "$CurrentFolder\ReVanced\$($url.name)"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
@@ -129,11 +172,13 @@ foreach($url in $URL) {
|
||||
}
|
||||
|
||||
# Sometimes older version of zulu-jdk causes conflict, so remove older version before proceeding.
|
||||
if (Test-Path -Path "$WorkingFolder\ReVanced\jdk")
|
||||
if (Test-Path -Path "$CurrentFolder\ReVanced\jdk")
|
||||
{
|
||||
Remove-Item -Path "$WorkingFolder\ReVanced\jdk" -Recurse -Force
|
||||
Remove-Item -Path "$CurrentFolder\ReVanced\jdk" -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Verbose -Message "" -Verbose
|
||||
Write-Verbose -Message "Downloading Azul Zulu" -Verbose
|
||||
# https://github.com/ScoopInstaller/Java/blob/master/bucket/zulu-jdk.json
|
||||
$Parameters = @{
|
||||
Uri = "https://raw.githubusercontent.com/ScoopInstaller/Java/master/bucket/zulu-jdk.json"
|
||||
@@ -143,7 +188,7 @@ $Parameters = @{
|
||||
$URL = (Invoke-RestMethod @Parameters).architecture."64bit".url
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "$WorkingFolder\ReVanced\jdk_windows-x64_bin.zip"
|
||||
Outfile = "$CurrentFolder\ReVanced\jdk_windows-x64_bin.zip"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
@@ -151,33 +196,41 @@ Invoke-RestMethod @Parameters
|
||||
|
||||
# Expand jdk_windows-x64_bin archive
|
||||
$Parameters = @{
|
||||
Path = "$WorkingFolder\ReVanced\jdk_windows-x64_bin.zip"
|
||||
DestinationPath = "$WorkingFolder\ReVanced\jdk"
|
||||
Path = "$CurrentFolder\ReVanced\jdk_windows-x64_bin.zip"
|
||||
DestinationPath = "$CurrentFolder\ReVanced\jdk"
|
||||
Force = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Expand-Archive @Parameters
|
||||
|
||||
Remove-Item -Path "$WorkingFolder\ReVanced\jdk_windows-x64_bin.zip" -Force
|
||||
Remove-Item -Path "$CurrentFolder\ReVanced\jdk_windows-x64_bin.zip" -Force
|
||||
|
||||
# Let's create patched APK
|
||||
& "$WorkingFolder\ReVanced\jdk\zulu*win_x64\bin\java.exe" `
|
||||
-jar "$WorkingFolder\ReVanced\revanced-cli.jar" patch `
|
||||
--patch-bundle "$WorkingFolder\ReVanced\revanced-patches.jar" `
|
||||
--merge "$WorkingFolder\ReVanced\revanced-integrations.apk" `
|
||||
--exclude "Always repeat" `
|
||||
--exclude "Hide captions button" `
|
||||
--exclude "Hide timestamp" `
|
||||
--exclude "Hide seekbar" `
|
||||
& "$CurrentFolder\ReVanced\jdk\zulu*win_x64\bin\java.exe" `
|
||||
-jar "$CurrentFolder\ReVanced\revanced-cli.jar" patch `
|
||||
--patches "$CurrentFolder\ReVanced\revanced-patches.rvp" `
|
||||
--disable "Always repeat" `
|
||||
--disable "Disable auto captions" `
|
||||
--disable "Hide timestamp" `
|
||||
--disable "Hide seekbar" `
|
||||
--purge `
|
||||
--temporary-files-path "$WorkingFolder\ReVanced\Temp" `
|
||||
--out "$WorkingFolder\ReVanced\revanced.apk" `
|
||||
"$WorkingFolder\ReVanced\youtube.apk"
|
||||
--temporary-files-path "$CurrentFolder\ReVanced\Temp" `
|
||||
--out "$CurrentFolder\ReVanced\revanced.apk" `
|
||||
"$CurrentFolder\ReVanced\youtube.apk"
|
||||
|
||||
# Open working directory with builded files
|
||||
# Invoke-Item -Path "$WorkingFolder\ReVanced"
|
||||
# Invoke-Item -Path "$CurrentFolder\ReVanced"
|
||||
|
||||
# Remove temp directory, because cli failed to clean up directory
|
||||
# Remove-Item -Path "$WorkingFolder\ReVanced\Temp" -Recurse -Force -Confirm:$false
|
||||
# Remove-Item -Path "$CurrentFolder\ReVanced\Temp" -Recurse -Force -Confirm:$false
|
||||
|
||||
Write-Warning -Message "Latest available revanced.apk & microg.apk are ready in `"$WorkingFolder\ReVanced`""
|
||||
$Files = @(
|
||||
"$CurrentFolder\ReVanced\Temp",
|
||||
"$CurrentFolder\ReVanced\jdk",
|
||||
"$CurrentFolder\ReVanced\revanced-cli.jar",
|
||||
"$CurrentFolder\ReVanced\revanced-patches.rvp",
|
||||
"$CurrentFolder\ReVanced\youtube.apk"
|
||||
)
|
||||
Remove-Item -Path $Files -Recurse -Force
|
||||
|
||||
Write-Warning -Message "Latest available revanced.apk & microg.apk are ready in `"$CurrentFolder\ReVanced`""
|
||||
|
||||
@@ -14,7 +14,7 @@ Build ReVanced package (.apk) easily than ever using latest ReVanced patches and
|
||||
* hide-captions-button
|
||||
* hide-timestamp
|
||||
* hide-seekbar
|
||||
* The script downloads latest available YouTube package (having parsed [ReVanced API](https://api.revanced.app/v2/patches/latest)) supported by ReVanced Team from <https://apkpure.net> and all dependencies and build package using [Zulu JDK](https://www.azul.com/downloads/?package=jdk);
|
||||
* The script downloads latest available YouTube package (having parsed [ReVanced API](https://api.revanced.app/v4/patches/list)) supported by ReVanced Team from [APKMirror](https://apkmirror.com) and all dependencies and build package using [Zulu JDK](https://www.azul.com/downloads/?package=jdk);
|
||||
* Script installs no apps — everything will be held in your `Script location folder\ReVanced`;
|
||||
* After compiling you get `revanced.apk` & `microg.apk` ready to be installed;
|
||||
* Release notes are generated dynamically using the [ReleaseNotesTemplate.md](https://github.com/JDM170/ReVanced_Builder/blob/main/ReleaseNotesTemplate.md) template.
|
||||
@@ -30,14 +30,15 @@ Trigger the [`Build`](https://github.com/JDM170/ReVanced_Builder/actions/workflo
|
||||
## Requirements if you compile locally
|
||||
|
||||
* Windows 10 x64 or Windows 11
|
||||
* Windows PowerShell 5.1/7
|
||||
* Windows PowerShell 5.1
|
||||
* if you want to use PowerShell 7, you will have to install a 3rd party HTML parser ([AngleSharp](https://github.com/AngleSharp/AngleSharp))
|
||||
|
||||
## Links
|
||||
|
||||
* [APKPure](https://apkpure.net)
|
||||
* [APKMirror](https://apkmirror.com)
|
||||
* [ReVanced CLI](https://github.com/revanced/revanced-cli)
|
||||
* [ReVanced Patches](https://github.com/revanced/revanced-patches)
|
||||
* [ReVanced Integrations](https://github.com/revanced/revanced-integrations)
|
||||
* [ReVanced MicroG](https://github.com/ReVanced/GmsCore)
|
||||
* [AngleSharp](https://github.com/AngleSharp/AngleSharp)
|
||||
* [Zulu JDK](https://github.com/ScoopInstaller/Java)
|
||||
|
||||
@@ -3,6 +3,5 @@
|
||||
* YouTube YouTubeTag;
|
||||
* ReVanced CLI CLITag;
|
||||
* ReVanced Patches PatchesTag;
|
||||
* ReVanced Integrations IntegrationsTag;
|
||||
* ReVanced MicroG MicroGTag;
|
||||
* Azul Zulu ZuluTag.
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# https://github.com/revanced/revanced-integrations
|
||||
$Parameters = @{
|
||||
Uri = "https://api.github.com/repos/revanced/revanced-integrations/releases/latest"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
$apiResult = Invoke-RestMethod @Parameters
|
||||
$URL = ($apiResult.assets | Where-Object -FilterScript {$_.content_type -eq "application/vnd.android.package-archive"}).browser_download_url
|
||||
$TAG = $apiResult.tag_name
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "Temp\revanced-integrations.apk"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-RestMethod @Parameters
|
||||
|
||||
echo "IntegrationsTag=$TAG" >> $env:GITHUB_ENV
|
||||
@@ -5,11 +5,11 @@ $Parameters = @{
|
||||
Verbose = $true
|
||||
}
|
||||
$apiResult = Invoke-RestMethod @Parameters
|
||||
$URL = ($apiResult.assets | Where-Object -FilterScript {$_.content_type -eq "application/java-archive"}).browser_download_url
|
||||
$URL = ($apiResult.assets | Where-Object -FilterScript {$_.content_type -eq "text/plain"}).browser_download_url
|
||||
$TAG = $apiResult.tag_name
|
||||
$Parameters = @{
|
||||
Uri = $URL
|
||||
Outfile = "Temp\revanced-patches.jar"
|
||||
Outfile = "Temp\revanced-patches.rvp"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
# Get the latest supported YouTube version to patch
|
||||
# https://api.revanced.app/docs/swagger
|
||||
$Parameters = @{
|
||||
Uri = "https://api.revanced.app/v2/patches/latest"
|
||||
Uri = "https://api.revanced.app/v4/patches/list"
|
||||
UseBasicParsing = $true
|
||||
}
|
||||
$JSON = (Invoke-RestMethod @Parameters).patches
|
||||
$versions = ($JSON | Where-Object -FilterScript {$_.compatiblePackages.name -eq "com.google.android.youtube"}).compatiblePackages.versions
|
||||
$LatestSupported = $versions | Sort-Object -Descending -Unique | Select-Object -First 1
|
||||
$JSON = (Invoke-Webrequest @Parameters).Content | ConvertFrom-Json
|
||||
$versions = ($JSON | Where-Object -FilterScript {$_.name -eq "Video ads"})
|
||||
$LatestSupported = $versions.compatiblePackages.'com.google.android.youtube' | Sort-Object -Descending -Unique | Select-Object -First 1
|
||||
|
||||
# We need a NON-bundle version
|
||||
# https://apkpure.net/ru/youtube/com.google.android.youtube/versions
|
||||
<#
|
||||
$Parameters = @{
|
||||
Uri = "https://apkpure.net/youtube/com.google.android.youtube/download/$($LatestSupported)"
|
||||
UseBasicParsing = $true
|
||||
@@ -24,5 +25,62 @@ $Parameters = @{
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-Webrequest @Parameters
|
||||
#>
|
||||
|
||||
$AngleSharpAssemblyPath = (Get-ChildItem -Path (Split-Path -Path (Get-Package -Name AngleSharp).Source) -Filter "*.dll" -Recurse | Where-Object -FilterScript {$_ -match "standard"} | Select-Object -Last 1).FullName
|
||||
Add-Type -Path $AngleSharpAssemblyPath
|
||||
|
||||
# Create parser object
|
||||
$angleparser = New-Object -TypeName AngleSharp.Html.Parser.HtmlParser
|
||||
|
||||
# Trying to find correct APK link (not BUNDLE)
|
||||
# https://www.apkmirror.com/apk/google-inc/youtube/
|
||||
$apkMirrorLink = "https://www.apkmirror.com/apk/google-inc/youtube/youtube-$($LatestSupported.replace('.', '-'))-release/"
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink
|
||||
UseBasicParsing = $false # Disabled
|
||||
Verbose = $true
|
||||
}
|
||||
$Request = Invoke-Webrequest @Parameters
|
||||
$Parsed = $angleparser.ParseDocument($Request.Content)
|
||||
$Parsed.All | Where-Object -FilterScript {$_.ClassName -match "table-row headerFont"} | ForEach-Object -Process {
|
||||
foreach($child in $_.children)
|
||||
{
|
||||
if ($child.InnerHtml -eq "nodpi")
|
||||
{
|
||||
$apkPackageLink = (($_.getElementsByTagName("a") | Select-Object -First 1).Href).Substring(57)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
$apkMirrorLink += $apkPackageLink # actual APK link (not BUNDLE)
|
||||
|
||||
# Get unique key to generate direct link
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink
|
||||
UseBasicParsing = $false # Disabled
|
||||
Verbose = $true
|
||||
}
|
||||
$Request = Invoke-Webrequest @Parameters
|
||||
$Parsed = $angleparser.ParseDocument($Request.Content)
|
||||
$Key = $Parsed.All | Where-Object -FilterScript {$_.ClassName -match "accent_bg btn btn-flat downloadButton"} | ForEach-Object -Process {$_.Search}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = $apkMirrorLink + "download/$($Key)"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
$Request = Invoke-Webrequest @Parameters
|
||||
$Parsed = $angleparser.ParseDocument($Request.Content)
|
||||
$Key = ($Parsed.All | Where-Object -FilterScript { $_.InnerHtml -eq "here" }).Search
|
||||
|
||||
# Finally, get the real link
|
||||
$Parameters = @{
|
||||
Uri = "https://www.apkmirror.com/wp-content/themes/APKMirror/download.php$Key"
|
||||
OutFile = "Temp\youtube.apk"
|
||||
UseBasicParsing = $true
|
||||
Verbose = $true
|
||||
}
|
||||
Invoke-Webrequest @Parameters
|
||||
|
||||
echo "LatestSupportedYT=$LatestSupported" >> $env:GITHUB_ENV
|
||||
|
||||
Reference in New Issue
Block a user