RapGenius-JS

Simple querying API for RapGenius

  • 所有者: kenshiro-o/RapGenius-JS
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

RapGenius-JS Build Status

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.

Rationale

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

Installation

$ npm install rapgenius-js

Usage

The API is very simple to use and currently enables you to perform the following:

Model objects

Artist

Artist
  - name: String
  - link: String
  - popularSongs: Array (of String)
  - songs: Array (of String)

Song

Song
  - name: String
  - artists: String
  - link: String

Lyrics

Verses
  - id: int
  - content: String
  - explanation: String

Section
  - name: String
  - content: String
  - verses: Array (of Verses)

Lyrics
  - songId: int
  - songTitle: String
  - mainArtist: String
  - featuringArtists: Array (of String)
  - producingArtists: Array (of String)
  - sections: Array (of Section)

Search for an artist:

var rapgeniusClient = require("rapgenius-js");

rapgeniusClient.searchArtist("GZA", "rap", 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);

  }
});

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

var rapgeniusClient = require("rapgenius-js");

rapgeniusClient.searchSong("Liquid Swords", "rap", function(err, songs){
  if(err){
    console.log("Error: " + err);
  }else{
    console.log("Songs that matched the search query were found" +
                "[songs-found=%d, first-song-name=%s", songs.length, songs[0].name);
  }
});

Search for the lyrics of a song along with their meaning:

var rapgeniusClient = require("rapgenius-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("\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
      rapgeniusClient.searchLyricsAndExplanations(songs[0].link, "rap", lyricsSearchCb);
    }
  }
};

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

Additional features

I will work on the following features when I get the time:

  • Refactor code base
  • Improve performance

Licence

MIT (Make It Tremendous)

主要指標

概覽
名稱與所有者kenshiro-o/RapGenius-JS
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證
所有者活动
創建於2013-01-18 23:12:29
推送於2017-06-22 13:17:56
最后一次提交2017-06-22 14:17:52
發布數0
用户参与
星數124
關注者數13
派生數18
提交數47
已啟用問題?
問題數5
打開的問題數1
拉請求數4
打開的拉請求數2
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?