Comparing version 1.0.0 to 1.0.1
67
index.js
@@ -0,2 +1,6 @@ | ||
#! /usr/bin/env node | ||
'use strict'; | ||
var promise = require('promise'); | ||
var promiseRetry = require('promise-retry'); | ||
var request = require('request'); | ||
@@ -31,6 +35,6 @@ const pIf = require('p-if'); | ||
fulfill(tracks[rnd]); | ||
} else { reject(Error('No tracks found')); } | ||
} else { reject('No tracks found'); } | ||
} else { reject(error); } | ||
}); | ||
} else { reject(Error('No tracks found')); } | ||
} else { reject('No tracks found'); } | ||
} else { reject(error); } | ||
@@ -55,3 +59,3 @@ }) | ||
fulfill(body.message.body); | ||
} else { reject(Error('Item not found')); } | ||
} else { reject('Item not found'); } | ||
} else { reject(error); } | ||
@@ -65,17 +69,48 @@ }); | ||
genre = options.genre; | ||
snippet = options.snippet; | ||
snippet = (String(options.snippet).toLowerCase() == 'true'); | ||
language = options.language; | ||
getRandomTrack() | ||
.then(pIf(snippet, function(t){ | ||
return getById('track.snippet', t.track.track_id) | ||
.then(function(s){ t.snippet = s.snippet; return t; }); | ||
}) | ||
) | ||
.then(function(t){ | ||
cb(null, t); | ||
}) | ||
.catch(function(e){ | ||
cb(e); | ||
}); | ||
promiseRetry(function(retry, number){ | ||
return getRandomTrack() | ||
.then(pIf(snippet, function(t){ | ||
return getById('track.snippet', t.track.track_id) | ||
.then(function(s){ t.snippet = s.snippet; return t; }) | ||
.catch(retry); | ||
}) | ||
); | ||
}, { | ||
retries: 4, | ||
minTimeout: 0, | ||
maxTimeout: 0 | ||
}) | ||
.then(function(t){ | ||
cb(null, t); | ||
}) | ||
.catch(function(e){ | ||
cb(e); | ||
}); | ||
} | ||
if (require.main === module) { | ||
var options = {}; | ||
var varPrefix = 'rndSong_'; | ||
for (var key in process.env) { | ||
if (key.indexOf(varPrefix) == 0) { | ||
options[key.substring(varPrefix.length)] = process.env[key]; | ||
} | ||
} | ||
if (process.argv.length > 2) { | ||
for (var i = 2; i < process.argv.length; i++) { | ||
var arg = process.argv[i].split('='); | ||
options[arg[0]] = arg[1]; | ||
} | ||
} | ||
module.exports(options, function(error, response) { | ||
if (!error) { | ||
console.log(response); | ||
} else { console.log(new Error(error)); } | ||
}); | ||
} |
{ | ||
"name": "rnd-song", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A node module that returns a random song/album/artist via the Musixmatch API.", | ||
"keywords": ["random", "rnd", "music", "track", "song", "album", "artist", "lyric", "snippet", "musixmatch"], | ||
"keywords": [ | ||
"random", | ||
"rnd", | ||
"music", | ||
"track", | ||
"song", | ||
"album", | ||
"artist", | ||
"lyric", | ||
"snippet", | ||
"musixmatch" | ||
], | ||
"author": { | ||
@@ -21,4 +32,7 @@ "name": "Kodie Grantham", | ||
"main": "index.js", | ||
"bin": { | ||
"rnd-song": "index.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node index.js" | ||
}, | ||
@@ -28,4 +42,5 @@ "dependencies": { | ||
"promise": "^7.1.1", | ||
"promise-retry": "^1.1.1", | ||
"request": "^2.79.0" | ||
} | ||
} |
@@ -5,8 +5,9 @@ # rnd-song | ||
## Installation | ||
## Installation & Usage | ||
### via Module: | ||
#### Installation: | ||
``` | ||
$ npm install rnd-song --save | ||
$ npm i rnd-song -S | ||
``` | ||
## Usage | ||
#### Usage: | ||
```javascript | ||
@@ -28,6 +29,17 @@ var rndSong = require('rnd-song'); | ||
console.log(`Artist: ${res.track.artist_name}`); | ||
} else { throw err; } | ||
} else { console.log(new Error(err)); } | ||
}); | ||
``` | ||
### via Command Line Interface: | ||
#### Installation: | ||
```shell | ||
$ npm i rnd-song -g | ||
``` | ||
#### Usage: | ||
```shell | ||
$ export rndSong_api_key=s3EAqFptASYO7YR2lLItZfcfOj0VCpvt | ||
$ export rndSong_language=en | ||
$ rnd-song genre=14 snippet=true | ||
``` | ||
@@ -68,8 +80,8 @@ ## Options | ||
artist_name: 'Rihanna', | ||
album_coverart_100x100: 'http: //s.mxmcdn.net/images-storage/albums/nocover.png', | ||
album_coverart_100x100: 'http://s.mxmcdn.net/images-storage/albums/nocover.png', | ||
album_coverart_350x350: '', | ||
album_coverart_500x500: '', | ||
album_coverart_800x800: '', | ||
track_share_url: 'https: //www.musixmatch.com/lyrics/Rihanna/Take-a-Bow', | ||
track_edit_url: 'https: //www.musixmatch.com/lyrics/Rihanna/Take-a-Bow/edit?utm_source=application&utm_campaign=api&utm_medium=Kodie+Grantham', | ||
track_share_url: 'https://www.musixmatch.com/lyrics/Rihanna/Take-a-Bow', | ||
track_edit_url: 'https://www.musixmatch.com/lyrics/Rihanna/Take-a-Bow/edit?utm_source=application&utm_campaign=api&utm_medium=Kodie+Grantham', | ||
commontrack_vanity_id: 'Rihanna/Take-a-Bow', | ||
@@ -100,5 +112,5 @@ restricted: 0, | ||
snippet_body: 'But it\'s over now (but it\'s over now)', | ||
script_tracking_url: 'https: //tracking.musixmatch.com/t1.0/m_js/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
pixel_tracking_url: 'https: //tracking.musixmatch.com/t1.0/m_img/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
html_tracking_url: 'https: //tracking.musixmatch.com/t1.0/m_html/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
script_tracking_url: 'https://tracking.musixmatch.com/t1.0/m_js/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
pixel_tracking_url: 'https://tracking.musixmatch.com/t1.0/m_img/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
html_tracking_url: 'https://tracking.musixmatch.com/t1.0/m_html/e_0/sn_1/l_12080868/su_0/tr_VwPHgxSVfuIPJvwghgndMAbVlEgTMYDOJknA-zMFpPwbqm0z66GNIaXFcEz3QQPHzjuaECu6xhQ72jSi8xQj98kpU_6dvc_IoXs-T1kO-DfeFNHQUIuRDPQLNZ3A_mPuA6yNEvPbBTpu4nwnEF-d20v4IdOu9gTVuWZrU1ivZRVtZC0fubfXnP3G27k7tNLNE1FAOQWUxFsVWwcbqzkIqt24iuno_DYnM0Isl8hgl3NqGyBkAVPUkRoXYjT1ZGE3g3hME9iZAwyg4Cf2BOjeyzFzhExbYyMx_5fMfoGNa8W4GSFq8Wp_9Lfu0ZmYGXZ-MJbij0uhYO0ypjyDBQxR-EEEydMUg1BXGodOOLmnMppzjEizX_0G01AvyATZinLa/', | ||
updated_time: '2015-09-04T19: 49: 23Z' | ||
@@ -105,0 +117,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
12949
218
0
119
4
2
+ Addedpromise-retry@^1.1.1
+ Addederr-code@1.1.2(transitive)
+ Addedpromise-retry@1.1.1(transitive)
+ Addedretry@0.10.1(transitive)