35 lines
775 B
PowerShell
35 lines
775 B
PowerShell
param(
|
|
[string]$url = "",
|
|
[string]$out = "~/Videos/Downloads/",
|
|
[string]$namepattern = "%(title)s",
|
|
[int]$wait = 60 * 10
|
|
)
|
|
|
|
if (-not (Get-Command "yt-dlp" -ErrorAction SilentlyContinue)) {
|
|
Write-Host "There's no yt-dlp to work with!"
|
|
exit
|
|
}
|
|
|
|
if ($out -notmatch '\\$') {
|
|
$out += "\"
|
|
}
|
|
|
|
if (-not (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 (-not $url) { break }
|
|
Start-Process yt-dlp -ArgumentList "$ytdlp_options $url"
|
|
}
|
|
}
|