feat: add download in current directory
This commit is contained in:
parent
dffc773689
commit
30512b6f72
7
index.js
7
index.js
|
@ -1,11 +1,12 @@
|
||||||
const Cheerio = require('cheerio');
|
const Cheerio = require('cheerio');
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs, createWriteStream } = require('fs');
|
||||||
const debug = require('debug')('vk-music-dl');
|
const debug = require('debug')('vk-music-dl');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
const Request = require('request-promise');
|
const Request = require('request-promise');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const leven = require('leven');
|
const leven = require('leven');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +65,10 @@ async function main(i = 0){
|
||||||
return item;
|
return item;
|
||||||
}).sortBy('score').last().value();
|
}).sortBy('score').last().value();
|
||||||
debug(bestMatch);
|
debug(bestMatch);
|
||||||
|
await fetch(bestMatch.url).then(res => {
|
||||||
|
res.body.pipe(createWriteStream(`./${bestMatch.title} - ${bestMatch.artist}.mp3`));
|
||||||
|
});
|
||||||
|
debug('Done');
|
||||||
});
|
});
|
||||||
// best match for Love Is a Bitch id:456240390
|
// best match for Love Is a Bitch id:456240390
|
||||||
//const results = await searchOnVkMusic('Two Feet Love Is a Bitch');
|
//const results = await searchOnVkMusic('Two Feet Love Is a Bitch');
|
||||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -338,6 +338,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
},
|
},
|
||||||
|
"node-fetch": {
|
||||||
|
"version": "2.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||||
|
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||||
|
},
|
||||||
"nth-check": {
|
"nth-check": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"leven": "^3.1.0",
|
"leven": "^3.1.0",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"request-promise": "^4.2.5"
|
"request-promise": "^4.2.5"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user