Skip to content

Instantly share code, notes, and snippets.

@Strajk
Created November 29, 2024 06:49
Show Gist options
  • Select an option

  • Save Strajk/f7000ce9594ed734ba24cd54e2140a6b to your computer and use it in GitHub Desktop.

Select an option

Save Strajk/f7000ce9594ed734ba24cd54e2140a6b to your computer and use it in GitHub Desktop.
// Name: Lyrics on Genius
// Description: Look up Lyrics of Current Song on Rap Genius
// Acknowledgments:
// - Ryan Rudzitis: Look up Lyrics of Current Song on Rap Genius
import "@johnlindquist/kit"
let appsToTry = [
"Music",
"Spotify"
]
let qs: string
for (let app of appsToTry) {
qs = await applescript(/* applescript */ `
tell application "${app}"
if player state is playing then
set aTrack to the current track
set aName to name of aTrack
set aArtist to artist of aTrack
return quoted form of (aArtist & " - " & aName)
else
return ""
end if
end tell
`)
if (qs) break
}
if (!qs) {
notify(`No music is playing in: ` + appsToTry.join(", "))
} else {
open(`http://genius.com/search?q=${qs}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment