Last active
July 28, 2020 14:32
-
-
Save thomastay/50483e702a74b88ff4afb164c4e15a41 to your computer and use it in GitHub Desktop.
My personal wrapper for youtube-dl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding(SupportsShouldProcess = $True)] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[string]$URL, | |
[Switch]$audio, | |
[Switch]$ignoreErrors | |
) | |
$command = $URL, '-o', '%(title)s.%(ext)s' | |
if ($audio) { | |
$command += "-x", "--postprocessor-args", "`"-threads 2`"" | |
} | |
if ($ignoreErrors) { | |
$command += "--ignore-errors" | |
} | |
Write-Information "Executing Command..." | |
Write-Information ("youtube-dl " + ($command -join " ")) | |
Start-Process -NoNewWindow -Wait -FilePath "youtube-dl" -ArgumentList $command | |
<# | |
.SYNOPSIS | |
Downloads a file using youtube-dl. | |
.DESCRIPTION | |
Takes as input a URL, and a switch to download as MP3 | |
Uses youtube-dl (a Python extension) to download the files | |
.PARAMETER URL | |
Specifies the URL. Mandatory. | |
.PARAMETER audio | |
Switch, specifying if the video should be downloaded as an audio file | |
Note that this does not necessarily download an mp3 file, it might | |
download an .opus file | |
.PARAMETER ignoreErrors | |
Switch, specifying whether ytdl should Continue on download errors, | |
for example to skip unavailable videos in a playlist | |
.LINK | |
https://github.com/ytdl-org/youtube-dl | |
.EXAMPLE | |
PS> ./ytdl-wrapper -URL https://www.youtube.com/watch?v=yDOtENyOxyA -audio | |
.EXAMPLE | |
PS> ./ytdl-wrapper https://www.youtube.com/playlist?list=PLD6GNPaln5zKG4XKdMCN5YrgkIivJnkYd -ignoreErrors | |
.EXAMPLE | |
PS> ./ytdl-wrapper -URL https://www.youtube.com/watch?v=yDOtENyOxyA -WhatIf | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment