Daniel Miller

Daniel Miller

// 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)