Am automating youtubeDl tasks with Powershell via some functions in profile.ps1 This function accepts different parameters - if some are set, i'll setup additional config to youtube-dl executable.
For instance, executing ytDl https://vimeo.com/1548390390 would result in executing .\youtube-dl.exe https://vimeo.com/1548390390.
When executing ytDl https://vimeo.com/1548390390 3458F89 would lead to
.\youtube-dl.exe https://vimeo.com/1548390390 --video-password 3458F89
Am able to do what i want working script is not "beautiful"/"clean". I pasted below the two versions.
Can anyone of you help me - explain me why it's not behaving as expected ? Thanks a lot !
function ytDl_Working_But_NotBeautiful {
param (
[Parameter(Mandatory = $true, Position = 0)][string]$url,
[Parameter(Mandatory = $false, Position = 1)][string]$password,
[Parameter(Mandatory = $false, Position = 2)][string]$youtubeDlPath = "C:\APPS\"
)
Write-Host "URL = $url || Password = $password"
cd $youtubeDlPath
if ($password.Length -gt 0) {
Write-Host "Password set - adding video-password parameter"
.\youtube-dl.exe $url --video-password $password
}
else{
.\youtube-dl.exe $url
}
}
function ytDl_NotWorking {
param (
[Parameter(Mandatory = $true, Position = 0)][string]$url,
[Parameter(Mandatory = $false, Position = 1)][string]$password,
[Parameter(Mandatory = $false, Position = 2)][string]$youtubeDlPath = "C:\APPS\"
)
Write-Host "URL = $url || Password = $password"
$fullParams = $url
if ($password.Length -gt 0) {
Write-Host "Password set - adding video-password parameter"
$fullParams = "$url --video-password $password"
}
Write-Host ".\youtube-dl.exe $fullParams"
.\youtube-dl.exe $fullParams
}
ytDl https://vimeo.com/473689210 2345no [vimeo] 473689210: Downloading webpage [vimeo] 473689210: Extracting information [vimeo] 473689210: Verifying the passwordWhen launching ytDl2 with same param; it failsytDl2 https://vimeo.com/473689210 2345no Password set - adding video-password parameter [vimeo:user] 473689210 --video-password 2345no: Downloading page 1Which means parameters are not properly set. Thus this question :)