12-20-2020, 09:34 PM
(12-20-2020, 08:39 PM)Tim Curtis Wrote: What is the syntax of the search query?
Hi,
I tried several api-queries - it's not this easy to find a good & reliable one.
Finally I found genius-lyrics-api by farshed. It's using node.
I think it has everything of the possible queries available.
It's a bit lazy - but this could also be because of the overloaded Genius server...
I created a php script and a node script for querying the actual song playing
In order to use it, You will need to create a free account on Genius. Then You need to create a new API-Client in order to get the API-Key.
PHP Code:
<?php
$ARTIST_=shell_exec('mpc --format %artist% | head -n 1');
$ARTIST_=str_replace("\n","",$ARTIST_);
$TITLE_=shell_exec('mpc --format %title% | head -n 1');
$TITLE_=str_replace("\n","",$TITLE_);
$ret = shell_exec("node /home/pi/node/geniuslyrics.js '".$ARTIST_."' '".$TITLE_."'");
print_r($ret);
Code:
const { getLyrics, getSong } = require('genius-lyrics-api');
if (process.argv.length==4) {
var songtitle = process.argv[3]
var songartist = process.argv[2]
const options = {
apiKey: '>>>>YOUR API KEY<<<<',
title: songtitle,
artist: songartist,
optimizeQuery: true
};
getLyrics(options).then((lyrics) => console.log(lyrics));
};
//getSong(options).then((song) =>
// console.log(`
// ${song.id}
// ${song.url}
// ${song.albumArt}
// ${song.lyrics}`)
//);
here's a post describing to query the API with python: Getting Song Lyrics from Genius’s API + Scraping | Big-Ish Data
As I mentioned elswhere in my X-Mas wishlist, it would be really great to have lyrics included!
Cheers, Stephan