$ErrorActionPreference = "Stop" $Root = Split-Path -Parent $MyInvocation.MyCommand.Path $Assets = Join-Path $Root "assets\windows_hd" New-Item -ItemType Directory -Force -Path $Assets | Out-Null # Version stable utilisée uniquement comme bootstrap vérifié par SHA-256. # Le script passe ensuite automatiquement au canal nightly. $YtVersion = "2026.07.04" $YtBase = "https://github.com/yt-dlp/yt-dlp/releases/download/$YtVersion" $YtExe = Join-Path $Assets "yt-dlp.exe" $YtSums = Join-Path $env:TEMP "youtube-personal-yt-dlp-sha256.txt" $DenoVersion = "2.9.4" $DenoBase = "https://github.com/denoland/deno/releases/download/v$DenoVersion" $DenoZipName = "deno-x86_64-pc-windows-msvc.zip" $DenoZip = Join-Path $env:TEMP "youtube-personal-deno.zip" $DenoSum = Join-Path $env:TEMP "youtube-personal-deno.sha256sum" $DenoExtract = Join-Path $env:TEMP "youtube-personal-deno-extract" $DenoExe = Join-Path $Assets "deno.exe" function Assert-Sha256 { param( [Parameter(Mandatory = $true)][string]$File, [Parameter(Mandatory = $true)][string]$Expected ) $Actual = (Get-FileHash -Algorithm SHA256 -Path $File).Hash.ToLowerInvariant() $ExpectedNormalized = $Expected.Trim().ToLowerInvariant() if ($Actual -ne $ExpectedNormalized) { Remove-Item -Force -ErrorAction SilentlyContinue $File throw "SHA-256 incorrect pour $File`nAttendu: $ExpectedNormalized`nObtenu: $Actual" } } Write-Host "" Write-Host "=== YouTube Personal - Preparation HD/4K Windows ===" -ForegroundColor Cyan Write-Host "" Write-Host "[1/5] Telechargement bootstrap de yt-dlp stable $YtVersion..." Invoke-WebRequest -UseBasicParsing ` -Uri "$YtBase/yt-dlp.exe" ` -OutFile $YtExe Invoke-WebRequest -UseBasicParsing ` -Uri "$YtBase/SHA2-256SUMS" ` -OutFile $YtSums $YtLine = Get-Content $YtSums | Where-Object { $_ -match "\syt-dlp\.exe$" } | Select-Object -First 1 if (-not $YtLine) { throw "Impossible de lire le SHA-256 officiel de yt-dlp.exe." } $YtExpected = ($YtLine -split "\s+")[0] Assert-Sha256 -File $YtExe -Expected $YtExpected Write-Host "[2/5] yt-dlp stable verifie." -ForegroundColor Green Write-Host "[3/5] Mise a jour de yt-dlp vers le canal nightly..." & $YtExe --update-to nightly if ($LASTEXITCODE -ne 0) { throw "La mise a jour yt-dlp nightly a echoue." } $YtNightlyVersion = (& $YtExe --version).Trim() if (-not $YtNightlyVersion) { throw "Impossible de lire la version yt-dlp nightly." } Write-Host "yt-dlp nightly actif: $YtNightlyVersion" -ForegroundColor Green Write-Host "[4/5] Telechargement de Deno $DenoVersion..." Invoke-WebRequest -UseBasicParsing ` -Uri "$DenoBase/$DenoZipName" ` -OutFile $DenoZip Invoke-WebRequest -UseBasicParsing ` -Uri "$DenoBase/$DenoZipName.sha256sum" ` -OutFile $DenoSum # Le fichier .sha256sum de Deno n'utilise pas forcément le format # " ". Certaines releases utilisent un petit format # structuré avec des champs comme "path" et "hash". # # On extrait donc explicitement l'unique SHA-256 (64 caractères hexadécimaux) # au lieu de supposer que le premier mot de la ligne est le hash. $DenoChecksumText = Get-Content $DenoSum -Raw $DenoHashMatches = [regex]::Matches( $DenoChecksumText, '(?i)(?