Last active
February 23, 2023 06:04
-
-
Save milnak/b90f118c4d541af627df9760107d41c4 to your computer and use it in GitHub Desktop.
Convert spotify playlist via ctrl-a,ctrl-c to a CSV list of artist,title,uri
This file contains 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
# (Get-Clipboard) -split "`n" | .\Write-SpotifyTrackInfo.ps1 | Format-List | |
param( | |
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[String[]]$URIs | |
) | |
process { | |
$regex = '<title>(?<Title>.+).* - .*by (?<Artist>.+) \| Spotify<\/title>' | |
foreach ($uri in $URIs) { | |
if (-not ([uri]$uri).IsAbsoluteUri) { | |
continue | |
} | |
$response = Invoke-WebRequest -Uri $uri | |
$content = $response.Content.Substring(0, 250) | |
Write-Verbose "Content: $content" | |
if ($content -match $regex) { | |
[PSCustomObject]@{ | |
Artist = [Net.WebUtility]::HtmlDecode($Matches.Artist) | |
Title = [Net.WebUtility]::HtmlDecode($Matches.Title) | |
Uri = $uri | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment