genius-fetch
Advanced tools
Comparing version 0.1.0 to 1.0.0
{ | ||
"name": "genius-fetch", | ||
"version": "0.1.0", | ||
"description": "JS library for fetching data from Genius", | ||
"main": "lib/index.js", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "Fetch data from Genius", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "npm run prepare", | ||
"build:esm": "npx tsc -p tsconfig-esm.json", | ||
"build:cjs": "npx tsc -p tsconfig.json", | ||
"prepare": "rm -rf dist && npm run build:esm && npm run build:cjs && bash fixup.sh", | ||
"lint": "npx eslint ./src && npx eslint ./examples", | ||
"lint:fix": "npx eslint ./src --fix && npx eslint ./examples --fix", | ||
"doc": "npx typedoc", | ||
"example": "func() { npx ts-node -P ./tsconfig-esm.json --esm ./examples/${1}.ts; }; func" | ||
}, | ||
"main": "./dist/cjs/index-cjs.js", | ||
"module": "./dist/mjs/index.js", | ||
"types": "./dist/mjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/mjs/index.d.ts", | ||
"default": "./dist/mjs/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index-cjs.js" | ||
} | ||
} | ||
}, | ||
"author": "Patrick Kan <patrickkfkan@gmail.com> (https://github.com/patrickkfkan)", | ||
"repository": { | ||
@@ -13,2 +36,30 @@ "type": "git", | ||
}, | ||
"license": "MIT", | ||
"directories": { | ||
"dist": "./dist" | ||
}, | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.18.38", | ||
"@types/node-fetch": "^2.6.4", | ||
"@types/unescape-js": "^1.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.56.0", | ||
"@typescript-eslint/parser": "^5.56.0", | ||
"eslint": "^8.36.0", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.24.0", | ||
"typedoc-plugin-markdown": "^3.14.0", | ||
"typedoc-plugin-rename-defaults": "^0.6.4", | ||
"typescript": "^4.9.5" | ||
}, | ||
"dependencies": { | ||
"bottleneck": "^2.19.5", | ||
"node-cache": "^5.1.2", | ||
"node-fetch": "^2.6.9", | ||
"string-similarity-js": "^2.1.4", | ||
"unescape-js": "^1.1.4" | ||
}, | ||
"keywords": [ | ||
@@ -21,12 +72,3 @@ "genius", | ||
"lyrics" | ||
], | ||
"author": "Patrick Kan", | ||
"license": "MIT", | ||
"dependencies": { | ||
"bottleneck": "^2.19.5", | ||
"node-cache": "^5.1.2", | ||
"node-fetch": "^2.6.7", | ||
"string-similarity-js": "^2.1.4", | ||
"unescape-js": "^1.1.4" | ||
} | ||
] | ||
} |
# genius-fetch | ||
A JS library for fetching data from [Genius](https://genius.com/) . Requires a Genius Access Token for certain functions. | ||
Fetch data from [Genius](https://genius.com/) . Requires a Genius Access Token for certain functions. | ||
@@ -14,2 +14,5 @@ # Installation | ||
``` | ||
// ESM | ||
import Genius from 'genius-fetch'; | ||
// CJS | ||
const Genius = require('genius-fetch'); | ||
@@ -49,6 +52,6 @@ | ||
const options = { | ||
textFormat: 'plain', | ||
textFormat: TextFormat.Plain, | ||
obtainFullInfo: true | ||
}; | ||
return client.getSongsByBestMatch(matchParams, options).then(result => { | ||
return client.getSongsByBestMatch(matchParams, options).then((result) => { | ||
// Do something with result | ||
@@ -60,3 +63,3 @@ }); | ||
Each function returns a Promise which resolves to the fetched data. | ||
Each function returns a Promise that resolves to the fetched data. | ||
@@ -74,6 +77,6 @@ ## Fetching by ID | ||
|------------|----------------------------------------------------------------| | ||
| textFormat | Formatting to apply, where applicable: `html`, `plain` or `dom`. Default: `html`. | | ||
| raw | Whether to return raw data. Default `false`. | | ||
| textFormat | Formatting to apply, where applicable: `TextFormat.HTML`, `TextFormat.Plain` or `TextFormat.DOM`. Default: `TextFormat.HTML`. | | ||
| raw | Whether to return raw data. Default: `false`. | | ||
Returns an object representing the requested resource. | ||
Returns a Promise that resolves to an object representing the requested resource (i.e., [Song](./docs/api/interfaces/Song.md), [Album](./docs/api/interfaces/Album.md) or [Artist](./docs/api/interfaces/Artist.md)). | ||
@@ -93,6 +96,6 @@ ## Fetching by Name | ||
| obtainFullInfo | Whether to fetch full info for each result by calling `get<Song/Album/Artist>ById()`. If `false`, only snippet info will be returned. If `true`, you should make sure you have configured the library with the `accessToken` config option. Default: `false`. | | ||
| textFormat | Formatting to apply, where applicable: `html`, `plain` or `dom`. Default: `html`. | | ||
| textFormat | Formatting to apply, where applicable: `TextFormat.HTML`, `TextFormat.Plain` or `TextFormat.DOM`. Default: `TextFormat.HTML`. | | ||
| raw | Whether to return raw data. Default `false`. | | ||
Returns an object with the following properties: | ||
Returns a Promise that resolves to an object with the following properties: | ||
@@ -102,3 +105,3 @@ | **Property** | **Description** | | ||
| q | The name searched. | | ||
| items | An array of objects representing the fetched resources. | | ||
| items | An array of objects representing the fetched resources (i.e., [Song](./docs/api/interfaces/Song.md), [Album](./docs/api/interfaces/Album.md) or [Artist](./docs/api/interfaces/Artist.md)). | | ||
| limit | The number of results requested. | | ||
@@ -127,3 +130,3 @@ | offset | The offset from which results are returned. | | ||
| sampleSize | The number of songs to fetch for best-matching. If it is smaller than `limit`, it will automatically be set to the same value as `limit`. Default: 20. | | ||
| textFormat | Formatting to apply, where applicable: `html`, `plain` or `dom`. Default: `html`. | | ||
| textFormat | Formatting to apply, where applicable: `TextFormat.HTML`, `TextFormat.Plain` or `TextFormat.DOM`. Default: `TextFormat.HTML`. | | ||
| obtainFullInfo* | Whether to fetch full info for each result by calling `getSongById()`. If `false`, only snippet info will be returned. If `true`, you should make sure you have configured the library with the `accessToken` config option. Default: `false`. | | ||
@@ -157,3 +160,3 @@ | ||
| sampleSize | The number of albums to fetch for best-matching. If it is smaller than `limit`, it will automatically be set to the same value as `limit`. Default: 20. | | ||
| textFormat | Formatting to apply, where applicable: `html`, `plain` or `dom`. Default: `html`. | | ||
| textFormat | Formatting to apply, where applicable: `TextFormat.HTML`, `TextFormat.Plain` or `TextFormat.DOM`. Default: `TextFormat.HTML`. | | ||
| obtainFullInfo* | Whether to fetch full info for each result by calling `getSongById()`. If `false`, only snippet info will be returned. If `true`, you should make sure you have configured the library with the `accessToken` config option. Default: `false`. | | ||
@@ -173,3 +176,3 @@ | ||
Returns an object with the following properties: | ||
Returns a Promise that resolves to an object with the following properties: | ||
@@ -181,4 +184,23 @@ | **Property** | **Description** | | ||
# Running the Examples | ||
First, provide your Genius Access Token in `./examples/accessToken.ts`. | ||
Then: | ||
``` | ||
$ npm run example <name of example script (without .ts file extension)> | ||
``` | ||
E.g. | ||
``` | ||
$ npm run example getSongsByName | ||
``` | ||
# Changelog | ||
1.0.0 | ||
- Migrate to TypeScript | ||
- Package as ESM + CJS hybrid module | ||
0.1.0 | ||
@@ -185,0 +207,0 @@ - Initial release |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
257696
88
2038
1
202
Yes
12
Updatednode-fetch@^2.6.9