Skip to content

Commit a176a48

Browse files
committed
fix: move myCookies variable initialization to maintain scope and improve cookie handling logic
close #18
1 parent 3494b95 commit a176a48

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

powershell/yt-download.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ $Defaults = @{
7272
autoAudio = @("https://music.youtube.com/watch?v=")
7373
browserCookies = "firefox"
7474
DownloadFolderName = "yt-dlp"
75-
myCookies = ""
7675
SelectDownloadedFile = $true
7776
templateNameChannel = "%(uploader)s - %(title)s.%(ext)s"
7877
templateNameTitle = "%(title)s.%(ext)s"
@@ -93,6 +92,8 @@ foreach ($VarName in $Defaults.Keys) {
9392
Write-Host
9493
}
9594
}
95+
96+
$myCookies = ""
9697
#===========================================================================
9798

9899
New-Variable -Name FullDownloadDir -Value (Join-Path -Path "$DownloadsPath" -ChildPath "$DownloadFolderName") -Option Constant
@@ -617,7 +618,7 @@ if ($url -and -not $install -and -not $uninstall) {
617618
<#*==========================================================================
618619
* ℹ TEST COOKIES
619620
===========================================================================#>
620-
if (-not $UseBrowserCookies) {
621+
if ((-not $UseBrowserCookies) -and ($myCookies)) {
621622
# Test cookie path
622623
if (Test-Path -Path $myCookies) {
623624
Write-Host "`- Use user cookies from file" -ForegroundColor Green

0 commit comments

Comments
 (0)