Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

genius-lyrics-scrape

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genius-lyrics-scrape - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

src/client/functions/getSong.js

21

package.json
{
"name": "genius-lyrics-scrape",
"version": "1.1.0",
"version": "1.2.0",
"description": "Genius Lyrics Scraper",
"main": "index.js",
"main": "./src/index.js",
"scripts": {
"docgen": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -11,3 +12,3 @@ },

"type": "git",
"url": "git+ssh://git@gitlab.com/SeptSlept/node-genius-lyrics-scrape.git"
"url": "git+ssh://git@gitlab.com/SeptSlept/genius-lyrics-scrape.git"
},

@@ -17,8 +18,8 @@ "author": "SeptSlept",

"bugs": {
"url": "https://gitlab.com/SeptSlept/node-genius-lyrics-scrape/issues"
"url": "https://gitlab.com/SeptSlept/genius-lyrics-scrape/issues"
},
"homepage": "https://gitlab.com/SeptSlept/node-genius-lyrics-scrape#readme",
"homepage": "https://gitlab.com/SeptSlept/genius-lyrics-scrape#readme",
"dependencies": {
"axios": "^0.19.0",
"cheerio": "^1.0.0-rc.3"
"cheerio": "^1.0.0-rc.3",
"phin": "^3.4.1"
},

@@ -33,3 +34,7 @@ "keywords": [

"client"
]
],
"devDependencies": {
"clean-jsdoc-theme": "^2.2.8",
"jsdoc": "^3.6.3"
}
}

@@ -8,2 +8,3 @@ # Genius Lyrics Scraper

+ [Example Usage](#usage)
+ [Documentation](#docs)
<!-- + [Contributing](../CONTRIBUTING.md) -->

@@ -51,1 +52,4 @@

```
## Documentation <a name = "docs"></a>
See the documentation [here](https://septslept.gitlab.io/genius-lyrics-scrape/index)

@@ -6,3 +6,11 @@ const constants = require('../util/constants.js')

const getSongByArtist = require('./functions/getSongByArtist.js')
const getSong = require('./functions/getSong.js')
// Structures
/* eslint-disable */
const SearchResult = require('../structures/SearchResult')
const Artist = require('../structures/Artist')
const Song = require('../structures/Song')
/* eslint-enable */
/**

@@ -35,5 +43,5 @@ * The main hub for interacting with the Genius API

/**
* Searches Lyrics using Genius API
* Searches Genius API for query. This also works for Genius URL query
* @param {String} query
* @returns {Promise<import('../structures/SearchResult')>}
* @returns {Promise<SearchResult>}
*/

@@ -47,3 +55,3 @@ searchAPI (query) {

* @param {Number} id The Artist's Genius ID
* @returns {Promise<import('../structures/Artist.js')>} Artist
* @returns {Promise<Artist>} Artist
*/

@@ -55,6 +63,15 @@ getArtist (id) {

/**
* Gets Song by ID
* @param {Number} id The Song's Genius ID
* @returns {Promise<Song>} Song
*/
getSong (id) {
return getSong(id, this.token)
}
/**
* Gets the list of song created by the artist
* @param {Number} id The Artist's Genius ID
* @param {Object} [opts] Optional options
* @returns {Promise<import('../structures/Song')[]>}
* @returns {Promise<Song[]>}
*/

@@ -61,0 +78,0 @@ getSongByArtist (id, opts) {

@@ -1,2 +0,2 @@

const axios = require('axios').default
const phin = require('phin')
const Artist = require('../../structures/Artist.js')

@@ -11,5 +11,10 @@

return new Promise((resolve, reject) => {
axios.get(`https://api.genius.com/artists/${id}`, { headers: { Authorization: 'Bearer ' + token } })
phin({
method: 'GET',
url: `https://api.genius.com/artists/${id}`,
headers: { Authorization: 'Bearer ' + token },
parse: 'json'
})
.then(res => {
const artistData = res.data.response.artist
const artistData = res.body.response.artist
const artist = new Artist(artistData)

@@ -16,0 +21,0 @@

@@ -1,8 +0,13 @@

const axios = require('axios').default
const phin = require('phin')
const Song = require('../../structures/Song.js')
// Structures
/* eslint-disable */
const constants = require('../../util/constants')
/* eslint-enable */
/**
* Gets the list of song created by the artist
* @param {Number} id The artist's Genius ID
* @param {import('../../util/constants').getSongByArtistOptions} options Optional Options
* @param {constants.getSongByArtistOptions} options Optional Options
* @param {String} token Genius' token

@@ -13,5 +18,9 @@ * @returns {Promise<Song[]>} Song array

return new Promise((resolve, reject) => {
axios.get(`https://api.genius.com/artists/${id}/songs?sort=${options.sort}&per_page=${options.per_page}`, { headers: { Authorization: 'Bearer ' + token } })
phin({
url: `https://api.genius.com/artists/${id}/songs?sort=${options.sort}&per_page=${options.per_page}`,
headers: { Authorization: 'Bearer ' + token },
parse: 'json'
})
.then(res => {
const songRaw = res.data.response.songs
const songRaw = res.body.response.songs
const songs = []

@@ -18,0 +27,0 @@

@@ -1,2 +0,2 @@

const axios = require('axios').default
const phin = require('phin')
const cheerio = require('cheerio')

@@ -13,5 +13,7 @@

axios.get(url)
phin({
url: url
})
.then((rawFetch) => {
rawFetch = rawFetch.data
rawFetch = rawFetch.body

@@ -18,0 +20,0 @@ try {

@@ -1,22 +0,36 @@

const axios = require('axios').default
const phin = require('phin')
const SearchResult = require('../../structures/SearchResult.js')
// Structures
/* eslint-disable */
const Song = require('../../structures/Song')
/* eslint-enable */
/**
* Searches Genius API for query
* Searches Genius API for query. This also works for Genius URL query
* @async
* @param {String} query
* @param {String} input Query
* @param {String} token Genius API token
* @returns {Promise<import('../../structures/SearchResult.js')>} Search result
* @returns {Promise<SearchResult>} Search result
*/
function searchAPI (query, token) {
function searchAPI (input, token) {
return new Promise((resolve, reject) => {
const querySanitized = encodeURI(query)
const options = {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`
}
// String and URL
let query
try { // URL
const url = new URL(input)
query = url.pathname.substr(1).split('-')
query.pop()
query = query.join(' ')
} catch {
query = input
}
axios('https://api.genius.com/search?q=' + querySanitized, options)
const querySanitized = encodeURI(query)
phin({
url: `https://api.genius.com/search?q=${querySanitized}`,
headers: { Authorization: `Bearer ${token}` },
parse: 'json'
})
.then((res) => {

@@ -27,3 +41,3 @@ /**

*/
const data = res.data
const data = res.body
const response = data.response

@@ -49,3 +63,3 @@

* @property {Object} response
* @property {import('../../structures/Song').GeniusHits} response.hits - Genius Hits
* @property {Song.GeniusHits} response.hits - Genius Hits
*/
const Song = require('./Song.js')
// Structures
/* eslint-disable */
const searchAPI = require('../client/functions/searchAPI.js')
/* eslint-enable */
/**

@@ -10,3 +15,3 @@ * Represents Genius' search result

* @constructor
* @param {import('../client/functions/searchAPI.js').GeniusAPIRes.response} data
* @param {searchAPI.GeniusAPIRes.response} data
*/

@@ -19,3 +24,3 @@ constructor (data) {

* Class setup function
* @param {import('../client/functions/searchAPI.js').GeniusAPIRes.response} data Response from Genius API
* @param {searchAPI.GeniusAPIRes.response} data Response from Genius API
* @private

@@ -22,0 +27,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc