Socket
Socket
Sign inDemoInstall

voc-cli

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

voc-cli - npm Package Compare versions

Comparing version 1.8.0 to 1.8.1

2

bin/dic/collins.js

@@ -154,3 +154,3 @@ 'use strict';

case 5:
err = new Error(word + ' is not found from collins');
err = new Error('\'' + word + '\' is not found from collins');

@@ -157,0 +157,0 @@ err.code = 'ENOENT';

@@ -151,3 +151,3 @@ 'use strict';

case 5:
err = new Error(word + ' is not found from freedictionary');
err = new Error('\'' + word + '\' is not found from freedictionary');

@@ -154,0 +154,0 @@ err.code = 'ENOENT';

@@ -75,2 +75,3 @@ 'use strict';

});
return _context.abrupt('return', set);

@@ -135,3 +136,4 @@

module.exports = _async_(regeneratorRuntime.mark(function _callee3(word) {
var set, url, list, err;
var urlSet, err, set, url, list, _err;
return regeneratorRuntime.wrap(function _callee3$(_context3) {

@@ -143,12 +145,25 @@ while (1) {

set = {};
_context3.next = 4;
_context3.next = 3;
return searchUrlSet(word);
case 4:
_context3.t0 = regeneratorRuntime.keys(_context3.sent);
case 3:
urlSet = _context3.sent;
case 5:
if (!(Object.keys(urlSet).length === 0)) {
_context3.next = 8;
break;
}
err = new Error('\'' + word + '\' is not found from webster');
err.code = 'ENOENT';
throw err;
case 8:
set = {};
_context3.t0 = regeneratorRuntime.keys(urlSet);
case 10:
if ((_context3.t1 = _context3.t0()).done) {
_context3.next = 15;
_context3.next = 20;
break;

@@ -160,6 +175,6 @@ }

_context3.t3 = set;
_context3.next = 11;
_context3.next = 16;
return getAudioSet(url);
case 11:
case 16:
_context3.t4 = _context3.sent;

@@ -169,19 +184,19 @@

_context3.next = 5;
_context3.next = 10;
break;
case 15:
case 20:
list = Object.keys(set);
if (!(list.length === 0)) {
_context3.next = 20;
_context3.next = 25;
break;
}
err = new Error(word + ' is not found from webster');
_err = new Error('\'' + word + '\' has no audio from webster');
err.code = 'ENOENT';
throw err;
_err.code = 'ENOENT';
throw _err;
case 20:
case 25:

@@ -198,3 +213,3 @@ // show all the audio url

case 22:
case 27:
case 'end':

@@ -201,0 +216,0 @@ return _context3.stop();

@@ -60,3 +60,3 @@ 'use strict';

var getAudioList = _async_(regeneratorRuntime.mark(function _callee2(word) {
var url, res, html, $, set, list;
var url, res, html, $, set, list, err;
return regeneratorRuntime.wrap(function _callee2$(_context2) {

@@ -95,5 +95,17 @@ while (1) {

// show all the audio url
list = Object.keys(set);
if (!(list.length === 0)) {
_context2.next = 17;
break;
}
err = new Error('\'' + word + '\' has no audio from yahoo');
err.code = 'ENOENT';
throw err;
case 17:
// show all the audio url
if (list.length > 1) {

@@ -108,3 +120,3 @@ list.forEach(function (audio, i) {

case 15:
case 19:
case 'end':

@@ -137,3 +149,3 @@ return _context2.stop();

case 5:
err = new Error(word + ' is not found from yahoo');
err = new Error('\'' + word + '\' is not found from yahoo');

@@ -140,0 +152,0 @@ err.code = 'ENOENT';

@@ -12,7 +12,11 @@ 'use strict';

function getAudioFileName(word, ext) {
// only convert ' ' to '_' here
return word.replace(/ /g, '_') + ext;
}
function getExistAudio(word, directory) {
var ext = ['.mp3', '.wav'];
for (var i = 0; i < ext.length; i++) {
var audio = path.resolve(directory, word + ext[i]);
var audio = path.resolve(directory, getAudioFileName(word, ext[i]));
try {

@@ -46,9 +50,8 @@ fs.statSync(audio);

_context.next = 5;
return serv.getUrl(word.replace(/_/g, ' '));
return serv.getUrl(word);
case 5:
url = _context.sent;
// replace '_' to ' '
ext = serv.ext || path.extname(url);
audioName = word.replace(/ /g, '_') + ext; // audio_xxx.mp3 or audio_xxx.wav
audioName = getAudioFileName(word, ext); // audio_xxx.mp3 or audio_xxx.wav

@@ -78,4 +81,6 @@ audioDest = path.resolve(directory, audioName); // audio destination

case 0:
word = normalize(word);
// only convert '_' to ' ' here
word = normalize(word).replace(/_/g, ' ');
// 1. force to download audio from particular service

@@ -150,3 +155,3 @@

// 3. audio is not found
err = new Error(word + ' is not found');
err = new Error('\'' + word + '\' is not found');

@@ -153,0 +158,0 @@ err.code = 'ENOENT';

@@ -168,3 +168,3 @@ 'use strict';

if (!(i < program.args.length)) {
_context.next = 65;
_context.next = 62;
break;

@@ -175,3 +175,3 @@ }

// remove extension '.mp3 or .wav' if any
// 6-1. remove extension '.mp3 or .wav' if any

@@ -184,18 +184,25 @@ reg = /\.(mp3|wav)$/;

audio = null;
_context.prev = 46;
_context.next = 49;
_context.prev = 45;
_context.next = 48;
return getAudio(word, config.directory, service);
case 49:
case 48:
audio = _context.sent;
_context.next = 56;
break;
// 6-3. play audio
console.log('play \'' + path.basename(audio) + '\' ...');
_context.next = 52;
return exec(config.audio_cli + ' "' + audio + '"');
case 52:
_context.prev = 52;
_context.t3 = _context['catch'](46);
_context.next = 59;
break;
case 54:
_context.prev = 54;
_context.t3 = _context['catch'](45);
if (!(_context.t3.code !== 'ENOENT')) {
_context.next = 56;
_context.next = 58;
break;

@@ -206,18 +213,8 @@ }

case 56:
if (!(audio === null)) {
_context.next = 59;
break;
}
case 58:
console.log('\'' + word + '\' is not found' + (service ? ' from ' + service : ''));
return _context.abrupt('continue', 62);
// it is not found or no audio
console.log(_context.t3.message);
case 59:
console.log('play \'' + path.basename(audio) + '\' ...');
_context.next = 62;
return exec(config.audio_cli + ' "' + audio + '"');
case 62:
i++;

@@ -227,3 +224,3 @@ _context.next = 41;

case 65:
case 62:
case 'end':

@@ -233,3 +230,3 @@ return _context.stop();

}
}, _callee, this, [[3, 7], [20, 25], [46, 52]]);
}, _callee, this, [[3, 7], [20, 25], [45, 54]]);
}));

@@ -0,1 +1,6 @@

## 1.8.1 (July 28, 2016)
- handle error case without audio in Webster and Yahoo ([#6](https://github.com/zlargon/voc/issues/6))
- it doesn't play sentence audio when the same audio has been downloaded ([#7](https://github.com/zlargon/voc/issues/7))
## 1.8.0 (July 28, 2016)

@@ -2,0 +7,0 @@

{
"name": "voc-cli",
"version": "1.8.0",
"version": "1.8.1",
"description": "download and play English vocabularies' audio via command line",

@@ -5,0 +5,0 @@ "main": "bin/getAudio.js",

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