2023-06-18 17:37:11 +00:00
|
|
|
param(
|
2023-06-19 03:50:25 +00:00
|
|
|
[string]$url = "",
|
|
|
|
[system.io.fileinfo]$out = "~/Videos/Downloads/",
|
|
|
|
[string]$namepattern = "%(title)s",
|
|
|
|
[int]$wait = 60 * 10
|
2023-06-18 17:37:11 +00:00
|
|
|
)
|
|
|
|
|
2023-06-22 15:37:38 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-06-19 03:50:25 +00:00
|
|
|
$ytdlp_options = "--live-from-start --sponsorblock-remove all"
|
|
|
|
$ytdlp_options += " --wait-for-video $wait"
|
|
|
|
$ytdlp_options += " --output $out$namepattern.%(ext)s"
|
2023-06-18 17:37:11 +00:00
|
|
|
|
|
|
|
if ($url) {
|
2023-06-19 03:50:25 +00:00
|
|
|
Start-Process yt-dlp -ArgumentList "$ytdlp_options $url"
|
2023-06-18 17:37:11 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
while ($true) {
|
|
|
|
$url = Read-host “URL”
|
|
|
|
if (!$url) { break }
|
2023-06-19 03:50:25 +00:00
|
|
|
Start-Process yt-dlp -ArgumentList "$ytdlp_options $url"
|
2023-06-18 17:37:11 +00:00
|
|
|
}
|
|
|
|
}
|