Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Created August 12, 2021 13:47
Show Gist options
  • Save dealingwith/11ca5e660d3873a3e521ad2905e2b5b7 to your computer and use it in GitHub Desktop.
Save dealingwith/11ca5e660d3873a3e521ad2905e2b5b7 to your computer and use it in GitHub Desktop.
// Menu: Genius Lyrics Search
let Genius = await npm('genius-lyrics-api')
let geniusUserToken = await env("GENIUS_AUTH_TOKEN")
import { getLyrics, searchSong } from 'genius-lyrics-api';
let songTitle = await arg("Song Title")
let options = {
apiKey: geniusUserToken,
title: songTitle,
artist: '',
optimizeQuery: true
}
let returnedSongs = await(searchSong(options).then((r) => r))
let returnedSongTitles = returnedSongs.map(s => s.title)
let chosenSongTitle = await arg("Which song?", returnedSongTitles)
let songData = returnedSongs.filter(s => s.title == chosenSongTitle)
let lyrics = await(getLyrics(songData[0].url).then((r) => r))
let whatToDo = await arg("", ["Copy", "View", "Visit"])
if (whatToDo == "Copy") copy(lyrics)
else if (whatToDo == "View") await textarea(lyrics)
else if (whatToDo == "Visit") await focusTab(songData[0].url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment