node-lyrics
Advanced tools
+58
| #!/usr/bin/env node --no-warnings | ||
| const { Readable } = require('stream'); | ||
| const meow = require('meow'); | ||
| const chalk = require('chalk'); | ||
| const { parseLyrics } = require('./'); | ||
| const cli = meow(chalk` | ||
| {yellow.bold Usage} | ||
| $ lyrics [artist] [song] [-c] | ||
| {yellow.bold Options} | ||
| -c, --clean Just lyrics without title | ||
| {yellow.bold Examples} | ||
| $ {green.bold lyrics} radiohead reckoner | ||
| {grey > radiohead - reckoner [In Rainbows]} | ||
| {grey > Reckoner,} | ||
| {grey > You can't take it with you, ..} | ||
| `, { | ||
| flags: { | ||
| clean: { | ||
| type: 'boolean', | ||
| alias: 'c', | ||
| default: false, | ||
| }, | ||
| } | ||
| }); | ||
| const [artist, song] = cli.input; | ||
| if (!artist || !song) { | ||
| cli.showHelp(); | ||
| } | ||
| const main = async () => { | ||
| const res = await parseLyrics(artist, song); | ||
| let lyrics = res.lyrics.split('\n').map((line) => { | ||
| if (line[0] == ',') { | ||
| line = line.substr(1, line.length); | ||
| } | ||
| return line; | ||
| }).join('\n'); | ||
| let title = `${artist} - ${song} [${res.album}]\n\n`; | ||
| if (cli.flags.clean) { | ||
| title = ''; | ||
| } | ||
| const body = `${title}${lyrics}`; | ||
| const outStream = new Readable({ read() {} }); | ||
| outStream.push(body); | ||
| outStream.pipe(process.stdout); | ||
| } | ||
| main(); |
+6
-1
| { | ||
| "name": "node-lyrics", | ||
| "version": "2.0.1", | ||
| "version": "2.1.0", | ||
| "description": "Get the lyrics to your favorite songs", | ||
@@ -14,2 +14,5 @@ "main": "index.js", | ||
| }, | ||
| "bin": { | ||
| "lyrics": "cli.js" | ||
| }, | ||
| "files": [ | ||
@@ -32,2 +35,3 @@ "index.js", | ||
| "dependencies": { | ||
| "chalk": "^2.4.2", | ||
| "cheerio": "1.0.0-rc.3", | ||
@@ -39,2 +43,3 @@ "lodash.assign": "^4.2.0", | ||
| "lodash.map": "^4.6.0", | ||
| "meow": "^5.0.0", | ||
| "superagent": "5.1.0" | ||
@@ -41,0 +46,0 @@ }, |
15994
9.44%12
9.09%354
14.94%9
28.57%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added