Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Created August 12, 2021 13:47
Show Gist options
  • Select an option

  • Save dealingwith/11ca5e660d3873a3e521ad2905e2b5b7 to your computer and use it in GitHub Desktop.

Select an option

Save dealingwith/11ca5e660d3873a3e521ad2905e2b5b7 to your computer and use it in GitHub Desktop.

Revisions

  1. dealingwith created this gist Aug 12, 2021.
    29 changes: 29 additions & 0 deletions song-search.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // 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)