Skip to content
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# RapGenius-JS [![Build Status](https://travis-ci.org/kenshiro-o/RapGenius-JS.png?branch=master)](https://travis-ci.org/kenshiro-o/RapGenius-JS)
# Genius-JS [![Build Status](https://travis-ci.org/kenshiro-o/RapGenius-JS.png?branch=master)](https://travis-ci.org/kenshiro-o/RapGenius-JS)

rapgenius-js is a simple client that enables you to query RapGenius(www.rapgenius.com) and retrieve
information about rap and rock artists and songs.
Genius-js is a simple client that enables you to query Genius(www.genius.com) and retrieve
information about rap and rock artists and songs. This project has been forked from kenshiro-o's RapGenius-JS and altered to support all areas of Genius rather than just Rap and Rock genius.

## Rationale

This project was created because RapGenius does currently not support a Node.js API.
This project was created because Genius does currently not support a Node.js API.

## Installation

```bash
$ npm install rapgenius-js
$ npm install genius-js
```

## Usage
Expand Down Expand Up @@ -54,36 +54,26 @@ $ npm install rapgenius-js
### Search for an artist:

```js
var rapgeniusClient = require("rapgenius-js");
var geniusClient = require("genius-js");

rapgeniusClient.searchArtist("GZA", "rap", function(err, artist){
rapgeniusClient.searchArtist("GZA", function(err, artist){
if(err){
console.log("Error: " + err);
}else{
console.log("Rap artist found [name=%s, link=%s, popular-songs=%d]",
console.log("Artist found [name=%s, link=%s, popular-songs=%d]",
artist.name, artist.link, artist.popularSongs.length);

}
});

//Example for a rock artist
rapgeniusClient.searchArtist("Bruce Springsteen", "rock", function(err, artist){
if(err){
console.log("Error: " + err);
}else{
console.log("Rap artist found [name=%s, link=%s, popular-songs=%d]",
artist.name, artist.link, artist.popularSongs.length);

}
});
```

### Search for a song:

```js
var rapgeniusClient = require("rapgenius-js");
var geniusClient = require("genius-js");

rapgeniusClient.searchSong("Liquid Swords", "rap", function(err, songs){
geniusClient.searchSong("Liquid Swords", "GZA", function(err, songs){
if(err){
console.log("Error: " + err);
}else{
Expand All @@ -96,7 +86,7 @@ rapgeniusClient.searchSong("Liquid Swords", "rap", function(err, songs){
### Search for the lyrics of a song along with their meaning:

```js
var rapgeniusClient = require("rapgenius-js");
var geniusClient = require("genius-js");

var lyricsSearchCb = function(err, lyricsAndExplanations){
if(err){
Expand All @@ -122,12 +112,12 @@ var searchCallback = function(err, songs){
}else{
if(songs.length > 0){
//We have some songs
rapgeniusClient.searchLyricsAndExplanations(songs[0].link, "rap", lyricsSearchCb);
geniusClient.searchLyricsAndExplanations(songs[0].link, lyricsSearchCb);
}
}
};

rapgeniusClient.searchSong("Liquid Swords", "rap", searchCallback);
geniusClient.searchSong("Liquid Swords", "GZA", searchCallback);
```


Expand Down
16 changes: 3 additions & 13 deletions examples/artistSearch.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
var rapgeniusClient = require("../src/geniusClient.js");
var geniusClient = require("../src/geniusClient.js");

rapgeniusClient.searchArtist("GZA", "rap", function(err, artist){
geniusClient.searchArtist("GZA", function(err, artist){
if(err){
console.log("Error: " + err);
}else{
console.log("Rap artist found [name=%s, link=%s, popular-songs=%d]",
console.log("Artist found [name=%s, link=%s, popular-songs=%d]",
artist.name, artist.link, artist.popularSongs.length);

}
});

//Example for a rock artist
rapgeniusClient.searchArtist("Bruce Springsteen", "rock", function(err, artist){
if(err){
console.log("Error: " + err);
}else{
console.log("Rap artist found [name=%s, link=%s, popular-songs=%d]",
artist.name, artist.link, artist.popularSongs.length);
}
});
6 changes: 3 additions & 3 deletions examples/lyricsSearch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var rapgeniusClient = require("../src/geniusClient");
var geniusClient = require("../src/geniusClient");

var lyricsSearchCb = function(err, lyricsAndExplanations){
if(err){
Expand All @@ -24,9 +24,9 @@ var searchCallback = function(err, songs){
}else{
if(songs.length > 0){
//We have some songs
rapgeniusClient.searchLyricsAndExplanations(songs[0].link, "rap", lyricsSearchCb);
geniusClient.searchLyricsAndExplanations(songs[0].link, lyricsSearchCb);
}
}
};

rapgeniusClient.searchSong("Liquid Swords", "rap", searchCallback);
geniusClient.searchSong("Liquid Swords", "GZA", searchCallback);
4 changes: 2 additions & 2 deletions examples/songSearch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var rapgeniusClient = require("../src/geniusClient");
var geniusClient = require("../src/geniusClient");

rapgeniusClient.searchSong("Liquid Swords", "rap", function(err, songs){
geniusClient.searchSong("Liquid Swords", "GZA", function(err, songs){
if(err){
console.log("Error: " + err);
}else{
Expand Down
34 changes: 34 additions & 0 deletions genius_api_lyrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var geniusClient = require("genius-js");

var lyricsSearchCb = function(err, lyricsAndExplanations){
if(err){
console.log("Error: " + err);
}else{
//Printing lyrics with section names
var lyrics = lyricsAndExplanations.lyrics;
var explanations = lyricsAndExplanations.explanations;
console.log("Found lyrics for song [title=%s, main-artist=%s, featuring-artists=%s, producing-artists=%s]",
lyrics.songTitle, lyrics.mainArtist, lyrics.featuringArtists, lyrics.producingArtists);
//console.log("**** LYRICS *****\n%s", lyrics.getFullLyrics(true));

//Now we can embed the explanations within the verses
lyrics.addExplanations(explanations);
var firstVerses = lyrics.sections[0].verses[0];
console.log(firstVerses.content.split('\n')[0]);
//console.log("\nVerses:\n %s \n\n *** This means ***\n%s", firstVerses.content, firstVerses.explanation);
}
};

var searchCallback = function(err, songs){
if(err){
console.log("Error: " + err);
}else{
if(songs.length > 0){
//We have some songs
console.log("SONG ID: " + songs[0].songId)
geniusClient.searchLyricsAndExplanations(songs[0].link, "r-b", lyricsSearchCb);
}
}
};
geniusClient.searchSong("Beat It", "r-b", searchCallback);
geniusClient.searchSong("Beat It", "rock", searchCallback);
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "rapgenius-js",
"name": "genius-js",
"description": "A client that queries the RapGenius (www.rapgenius.com) website",
"genius-js": "https://github.com/yuichitlo/Genius-JS/tarball/master",
"version": "0.1.2",
"keywords": ["rap", "rock", "rapgenius", "client", "lyrics", "music"],
"author": "kenshiro-o",
"author": "kenshiro-o, yuichitlo",
"main": "src/geniusClient",
"repository": {
"type": "git",
"url": "git://github.com/kenshiro-o/RapGenius-JS.git"
"url": "git://github.com/yuichitlo/Genius-JS.git"
},
"dependencies": {
"superagent": "0.12.x",
Expand Down
17 changes: 16 additions & 1 deletion src/constants/Constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
var Type2URLs = {
"urls": {
"artist_url":"http://genius.com/artists/",
"base_url":"http://genius.com",
"search_url":"http://genius.com/search",
"annotations_url": "http://genius.com/annotations/for_song_page"
},
"rock": {
"artist_url":"http://rock.rapgenius.com/artists/",
"base_url":"http://rock.rapgenius.com",
Expand All @@ -10,8 +16,13 @@ var Type2URLs = {
"base_url":"http://rapgenius.com",
"search_url":"http://rapgenius.com/search",
"annotations_url": "http://rapgenius.com/annotations/for_song_page"
},
"r-b": {
"artist_url":"http://r-b.genius.com/artists/",
"base_url": "http://r-b.genius.com",
"search_url": "http://r-b.genius.com/search",
"annotations_url": "http://r-b.genius.com/annotations/for_song_page"
}

};

module.exports.Type2URLs = Type2URLs;
Expand All @@ -23,3 +34,7 @@ module.exports.ROCK_RAP_GENIUS_ARTIST_URL = "http://rock.rapgenius.com/artists/"
module.exports.RAP_GENIUS_URL = "http://rapgenius.com";
module.exports.RAP_GENIUS_URL_SEARCH_URL = "http://rapgenius.com/search";
module.exports.RAP_GENIUS_ARTIST_URL = "http://rapgenius.com/artists/";

module.exports.RB_RAP_GENIUS_URL = "http://r-b.genius.com";
module.exports.RB_RAP_GENIUS_URL_SEARCH_URL = "http://r-b.genius.com/search";
module.exports.RB_RAP_GENIUS_ARTIST_URL = "http://r-b.genius.com/artists/";
25 changes: 25 additions & 0 deletions src/constants/Constants.js~
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var Type2URLs = {
"rock": {
"artist_url":"http://rock.rapgenius.com/artists/",
"base_url":"http://rock.rapgenius.com",
"search_url":"http://rock.rapgenius.com/search",
"annotations_url": "http://rock.rapgenius.com/annotations/for_song_page"
},
"rap": {
"artist_url":"http://rapgenius.com/artists/",
"base_url":"http://rapgenius.com",
"search_url":"http://rapgenius.com/search",
"annotations_url": "http://rapgenius.com/annotations/for_song_page"
}

};

module.exports.Type2URLs = Type2URLs;

module.exports.ROCK_RAP_GENIUS_URL = "http://rock.rapgenius.com";
module.exports.ROCK_RAP_GENIUS_URL_SEARCH_URL = "http://rock.rapgenius.com/search";
module.exports.ROCK_RAP_GENIUS_ARTIST_URL = "http://rock.rapgenius.com/artists/";

module.exports.RAP_GENIUS_URL = "http://rapgenius.com";
module.exports.RAP_GENIUS_URL_SEARCH_URL = "http://rapgenius.com/search";
module.exports.RAP_GENIUS_ARTIST_URL = "http://rapgenius.com/artists/";
Loading