PowerShell/Download-Video.ps1

31 lines
738 B
PowerShell

param(
[string]$url = "",
[system.io.fileinfo]$out = "~/Videos/Downloads/",
[string]$namepattern = "%(title)s",
[int]$wait = 60 * 10
)
if (!(Get-Command "yt-dlp.exe" -ErrorAction SilentlyContinue)) {
Write-Host "There's no yt-dlp.exe to work with!"
exit
}
if (!(Test-Path $out -PathType container)) {
New-Item $out -ItemType container
}
$ytdlp_options = "--live-from-start --sponsorblock-remove all"
$ytdlp_options += " --wait-for-video $wait"
$ytdlp_options += " --output $out$namepattern.%(ext)s"
if ($url) {
Start-Process yt-dlp -ArgumentList "$ytdlp_options $url"
}
else {
while ($true) {
$url = Read-host URL
if (!$url) { break }
Start-Process yt-dlp -ArgumentList "$ytdlp_options $url"
}
}