Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Idea: Genius
#4
(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
Reply


Messages In This Thread
Genius - by kit1cat - 12-20-2020, 08:18 PM
RE: Genius - by Tim Curtis - 12-20-2020, 08:39 PM
RE: Genius - by Stephanowicz - 12-20-2020, 09:34 PM
RE: Genius - by kit1cat - 12-20-2020, 09:24 PM
RE: Genius - by kit1cat - 12-20-2020, 09:43 PM
RE: Genius - by Stephanowicz - 12-22-2020, 05:19 PM
RE: Genius - by Stephanowicz - 12-24-2020, 06:54 PM
RE: Genius - by Tim Curtis - 12-24-2020, 10:06 PM
RE: Genius - by Stephanowicz - 01-17-2021, 11:42 AM
RE: Genius - by kit1cat - 01-17-2021, 12:31 PM
RE: Genius - by Stephanowicz - 01-17-2021, 12:58 PM
RE: Genius - by kit1cat - 01-17-2021, 05:00 PM
RE: Genius - by kit1cat - 01-17-2021, 05:56 PM

Forum Jump: