-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg-update.ps1
More file actions
62 lines (47 loc) · 1.94 KB
/
Copy pathffmpeg-update.ps1
File metadata and controls
62 lines (47 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# ================== Konfiguration ==================
$RepoApiUrl = "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest"
$AssetName = "ffmpeg-master-latest-win64-gpl.zip"
$BinTarget = "~/usr-bin"
$StateFile = "$PSScriptRoot/last_release.txt"
$TempDir = "$PSScriptRoot/ffmpeg_tmp"
$ZipPath = "$TempDir/$AssetName"
# GitHub mag User-Agent
$Headers = @{ "User-Agent" = "PowerShell" }
# ================== Vorbereitung ==================
New-Item -ItemType Directory -Path $TempDir -Force | Out-Null
New-Item -ItemType Directory -Path $BinTarget -Force | Out-Null
# ================== Release abrufen ==================
$release = Invoke-RestMethod -Uri $RepoApiUrl -Headers $Headers
$releaseId = $release.id
if (Test-Path $StateFile) {
$lastReleaseId = Get-Content $StateFile
if ($lastReleaseId -eq $releaseId) {
Write-Host "Kein neuer Release. Alles bleibt wie es ist."
exit 0
}
}
# ================== Asset finden ==================
$asset = $release.assets | Where-Object { $_.name -eq $AssetName }
if (-not $asset) {
throw "Release gefunden, aber Asset '$AssetName' existiert nicht."
}
# ================== Download ==================
Write-Host "Neuer Release erkannt. Lade FFmpeg herunter..."
Invoke-WebRequest `
-Uri $asset.browser_download_url `
-OutFile $ZipPath `
-Headers $Headers
# ================== Entpacken ==================
Expand-Archive -Path $ZipPath -DestinationPath $TempDir -Force
# ================== EXE-Dateien kopieren ==================
$exeFiles = Get-ChildItem -Path $TempDir -Recurse -Filter *.exe
foreach ($exe in $exeFiles) {
Copy-Item $exe.FullName -Destination $BinTarget -Force
}
# ================== Aufräumen ==================
if (Test-Path $TempDir) {
Remove-Item $TempDir -Recurse -Force
}
# ================== Release-Stand speichern ==================
Set-Content -Path $StateFile -Value $releaseId
Write-Host "FFmpeg erfolgreich aktualisiert."