108 lines
3.3 KiB
PowerShell
108 lines
3.3 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
$ProgressPreference = "SilentlyContinue"
|
|
|
|
Write-Host ""
|
|
Write-Host "=== YouTube Personal - PO Token Windows ==="
|
|
Write-Host ""
|
|
|
|
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ToolsRoot = Join-Path $ProjectRoot "assets\windows_hd"
|
|
$DenoExe = Join-Path $ToolsRoot "deno.exe"
|
|
|
|
if (-not (Test-Path $DenoExe)) {
|
|
throw "deno.exe absent dans assets\windows_hd. Lance d'abord PREPARER_HD_WINDOWS.ps1."
|
|
}
|
|
|
|
$InstallRoot = Join-Path $env:LOCALAPPDATA "YouTubePersonal\windows_hd"
|
|
$PluginDir = Join-Path $InstallRoot "yt-dlp-plugins"
|
|
$ProviderRoot = Join-Path $InstallRoot "bgutil-provider"
|
|
$ServerDir = Join-Path $ProviderRoot "server"
|
|
|
|
$Version = "1.3.1"
|
|
$PluginUrl = "https://github.com/Brainicism/bgutil-ytdlp-pot-provider/releases/download/$Version/bgutil-ytdlp-pot-provider.zip"
|
|
$SourceUrl = "https://github.com/Brainicism/bgutil-ytdlp-pot-provider/archive/refs/tags/$Version.zip"
|
|
|
|
$TempRoot = Join-Path $env:TEMP "youtube-personal-pot-provider"
|
|
$PluginTemp = Join-Path $TempRoot "bgutil-ytdlp-pot-provider.zip"
|
|
$SourceTemp = Join-Path $TempRoot "bgutil-source.zip"
|
|
$ExtractTemp = Join-Path $TempRoot "source"
|
|
|
|
if (Test-Path $TempRoot) {
|
|
Remove-Item $TempRoot -Recurse -Force
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $TempRoot | Out-Null
|
|
New-Item -ItemType Directory -Force -Path $PluginDir | Out-Null
|
|
New-Item -ItemType Directory -Force -Path $ProviderRoot | Out-Null
|
|
|
|
Write-Host "[1/5] Telechargement du plugin PO Token $Version..."
|
|
Invoke-WebRequest -Uri $PluginUrl -OutFile $PluginTemp
|
|
|
|
if ((Get-Item $PluginTemp).Length -lt 1000) {
|
|
throw "Le plugin telecharge semble invalide."
|
|
}
|
|
|
|
Copy-Item $PluginTemp (Join-Path $PluginDir "bgutil-ytdlp-pot-provider.zip") -Force
|
|
|
|
Write-Host "[2/5] Telechargement du provider BgUtils..."
|
|
Invoke-WebRequest -Uri $SourceUrl -OutFile $SourceTemp
|
|
|
|
Write-Host "[3/5] Extraction du provider..."
|
|
Expand-Archive -Path $SourceTemp -DestinationPath $ExtractTemp -Force
|
|
|
|
$ExtractedRoot = Get-ChildItem $ExtractTemp -Directory |
|
|
Where-Object { $_.Name -like "bgutil-ytdlp-pot-provider-*" } |
|
|
Select-Object -First 1
|
|
|
|
if (-not $ExtractedRoot) {
|
|
throw "Archive du provider invalide : dossier racine introuvable."
|
|
}
|
|
|
|
$ExtractedServer = Join-Path $ExtractedRoot.FullName "server"
|
|
|
|
if (-not (Test-Path $ExtractedServer)) {
|
|
throw "Dossier server du provider introuvable."
|
|
}
|
|
|
|
if (Test-Path $ServerDir) {
|
|
Remove-Item $ServerDir -Recurse -Force
|
|
}
|
|
|
|
Copy-Item $ExtractedServer $ServerDir -Recurse -Force
|
|
|
|
Write-Host "[4/5] Installation des dependances Deno du provider..."
|
|
Push-Location $ServerDir
|
|
try {
|
|
& $DenoExe install --allow-scripts=npm:canvas --frozen
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "deno install a echoue avec le code $LASTEXITCODE."
|
|
}
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
|
|
Write-Host "[5/5] Verification..."
|
|
$PluginInstalled = Join-Path $PluginDir "bgutil-ytdlp-pot-provider.zip"
|
|
|
|
if (-not (Test-Path $PluginInstalled)) {
|
|
throw "Plugin PO Token non installe."
|
|
}
|
|
|
|
if (-not (Test-Path (Join-Path $ServerDir "src"))) {
|
|
throw "Provider BgUtils incomplet."
|
|
}
|
|
|
|
Remove-Item $TempRoot -Recurse -Force
|
|
|
|
Write-Host ""
|
|
Write-Host "PO Token provider prepare avec succes."
|
|
Write-Host ""
|
|
Write-Host "Plugin : $PluginInstalled"
|
|
Write-Host "Provider: $ServerDir"
|
|
Write-Host ""
|
|
Write-Host "Commande suivante:"
|
|
Write-Host " flutter clean"
|
|
Write-Host " flutter run -d windows"
|