Compare commits

..

No commits in common. "96ac5a6f31ef02b9158d0678f0017eff1c148100" and "c41be73e3a2f478a30828f8a94ede7a953be9d1b" have entirely different histories.

3 changed files with 8 additions and 21 deletions

11
index.js Executable file → Normal file
View File

@ -10,7 +10,6 @@ const leven = require('leven');
const { URL, URLSearchParams } = require('url'); const { URL, URLSearchParams } = require('url');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const m3u = require('m3u'); const m3u = require('m3u');
const promisepipe = require('promisepipe');
require('dotenv').config(); require('dotenv').config();
@ -104,18 +103,12 @@ async function main(playlistUrl){
} }
bestMatch.path = `${bestMatch.artist} - ${bestMatch.title}.mp3`; bestMatch.path = `${bestMatch.artist} - ${bestMatch.title}.mp3`;
debug('bestMatch=%O', bestMatch); debug('bestMatch=%O', bestMatch);
try {
await fs.access(bestMatch.path).catch(async () => { // TODO find a proper way to not re-download, lower/uppercase problems await fs.access(bestMatch.path).catch(async () => { // TODO find a proper way to not re-download, lower/uppercase problems
await fetch(bestMatch.url).then(async res => { await fetch(bestMatch.url).then(res => {
await promisepipe(res.body, createWriteStream(bestMatch.path)); res.body.pipe(createWriteStream(bestMatch.path));
}); });
debug('Done downloading'); debug('Done downloading');
}); });
} catch (err) {
console.error('Download failed for ', bestMatch);
console.error(err);
return null;
}
return bestMatch; return bestMatch;
}, {concurrency: 1}); }, {concurrency: 1});

7
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "vk-music-dl", "name": "vk-music-dl",
"version": "1.0.6", "version": "1.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -164,11 +164,6 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"promisepipe": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/promisepipe/-/promisepipe-3.0.0.tgz",
"integrity": "sha512-V6TbZDJ/ZswevgkDNpGt/YqNCiZP9ASfgU+p83uJE6NrGtvSGoOcHLiDCqkMs2+yg7F5qHdLV8d0aS8O26G/KA=="
},
"readable-stream": { "readable-stream": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "vk-music-dl", "name": "vk-music-dl",
"version": "1.0.6", "version": "1.0.5",
"description": "Download Spotify playlist as mp3 from VKontakte", "description": "Download Spotify playlist as mp3 from VKontakte",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -33,8 +33,7 @@
"leven": "^3.1.0", "leven": "^3.1.0",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"m3u": "0.0.2", "m3u": "0.0.2",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0"
"promisepipe": "^3.0.0"
}, },
"devDependencies": {} "devDependencies": {}
} }