Add support for normal Spotify installs

This commit is contained in:
2025-05-07 19:41:16 +02:00
parent f8341181c2
commit 99454a3c39

View File

@@ -1,27 +1,49 @@
# Description: This script fixes Spotify playlist caching issues.
# get spotify path - might be different, i installed thru ms store
$spotifyBasePath = Join-Path $env:LOCALAPPDATA "Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0\LocalState\Spotify\Users"
# Define paths for both MS Store and regular installations
$msStorePath = Join-Path $env:LOCALAPPDATA "Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0\LocalState\Spotify\Users"
$regularPath = Join-Path $env:APPDATA "Spotify\Users"
if (Test-Path $spotifyBasePath) {
# i had multiple users, loop thru all of them
$userDirs = Get-ChildItem -Path $spotifyBasePath -Directory -Filter "*-user"
$foundUsers = $false
# Check MS Store installation
if (Test-Path $msStorePath) {
Write-Host "Found Microsoft Store Spotify installation"
$userDirs = Get-ChildItem -Path $msStorePath -Directory -Filter "*-user"
foreach ($userDir in $userDirs) {
# primary.ldb is a folder, not a file for some reason
$foundUsers = $true
$ldbPath = Join-Path $userDir.FullName "primary.ldb"
if (Test-Path $ldbPath -PathType Container) {
try {
Remove-Item -Path $ldbPath -Recurse -Force
Write-Host "Deleted: $ldbPath"
Write-Host "✓ Cleared cache for user in: $($userDir.Name)"
} catch {
Write-Warning "Failed to delete $ldbPath: $_"
}
} else {
Write-Host "No primary.ldb folder found at $ldbPath"
Write-Warning "Failed to clear cache in $($userDir.Name): $_"
}
}
}
} else {
Write-Warning "Spotify user directory not found at $spotifyBasePath"
}
# Check regular installation
if (Test-Path $regularPath) {
Write-Host "Found regular Spotify installation"
$userDirs = Get-ChildItem -Path $regularPath -Directory -Filter "*-user"
foreach ($userDir in $userDirs) {
$foundUsers = $true
$ldbPath = Join-Path $userDir.FullName "primary.ldb"
if (Test-Path $ldbPath -PathType Container) {
try {
Remove-Item -Path $ldbPath -Recurse -Force
Write-Host "✓ Cleared cache for user in: $($userDir.Name)"
} catch {
Write-Warning "Failed to clear cache in $($userDir.Name): $_"
}
}
}
}
if (-not $foundUsers) {
Write-Warning "No Spotify users found in either location:`n- $msStorePath`n- $regularPath"
} else {
Write-Host "`nDone! Restart Spotify to rebuild the cache."
}