youtube.ts
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -257,3 +257,3 @@ "use strict"; | ||
this.downloadVideo = function (videoResolvable, dest, ytdlOptions) { return __awaiter(_this, void 0, void 0, function () { | ||
var options, id, url, info, writeStream; | ||
var options, id, url, info, clean, writeStream; | ||
return __generator(this, function (_a) { | ||
@@ -292,2 +292,3 @@ switch (_a.label) { | ||
info = _a.sent(); | ||
clean = info.title.replace(/\//g, " ").replace(/\\/g, " "); | ||
if (!dest) | ||
@@ -299,6 +300,6 @@ dest = "./"; | ||
fs.mkdirSync(dest, { recursive: true }); | ||
writeStream = fs.createWriteStream(dest + "/" + info.title + ".mp4"); | ||
writeStream = fs.createWriteStream(dest + "/" + clean + ".mp4"); | ||
ytdl_core_1.default(url, options).pipe(writeStream); | ||
this.awaitStream(writeStream); | ||
return [2 /*return*/, dest + "/" + info.title + ".mp4"]; | ||
return [2 /*return*/, dest + "/" + clean + ".mp4"]; | ||
} | ||
@@ -376,3 +377,3 @@ }); | ||
this.downloadMP3 = function (videoResolvable, dest) { return __awaiter(_this, void 0, void 0, function () { | ||
var id, url, info, writeStream; | ||
var id, url, info, clean, writeStream; | ||
return __generator(this, function (_a) { | ||
@@ -387,2 +388,3 @@ switch (_a.label) { | ||
info = _a.sent(); | ||
clean = info.title.replace(/\//g, " ").replace(/\\/g, " "); | ||
if (!dest) | ||
@@ -394,6 +396,6 @@ dest = "./"; | ||
fs.mkdirSync(dest, { recursive: true }); | ||
writeStream = fs.createWriteStream(dest + "/" + info.title + ".mp3"); | ||
writeStream = fs.createWriteStream(dest + "/" + clean + ".mp3"); | ||
ytdl_core_1.default(url, { filter: "audioonly" }).pipe(writeStream); | ||
this.awaitStream(writeStream); | ||
return [2 /*return*/, dest + "/" + info.title + ".mp3"]; | ||
return [2 /*return*/, dest + "/" + clean + ".mp3"]; | ||
} | ||
@@ -400,0 +402,0 @@ }); |
@@ -153,9 +153,10 @@ import axios from "axios" | ||
const info = await ytdl.getInfo(url) | ||
const clean = info.title.replace(/\//g, " ").replace(/\\/g, " ") | ||
if (!dest) dest = "./" | ||
if (dest.endsWith("/")) dest = dest.slice(0, -1) | ||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, {recursive: true}) | ||
const writeStream = fs.createWriteStream(`${dest}/${info.title}.mp4`) | ||
const writeStream = fs.createWriteStream(`${dest}/${clean}.mp4`) | ||
ytdl(url, options).pipe(writeStream) | ||
this.awaitStream(writeStream) | ||
return `${dest}/${info.title}.mp4` | ||
return `${dest}/${clean}.mp4` | ||
} | ||
@@ -200,9 +201,10 @@ | ||
const info = await ytdl.getInfo(url) | ||
const clean = info.title.replace(/\//g, " ").replace(/\\/g, " ") | ||
if (!dest) dest = "./" | ||
if (dest.endsWith("/")) dest = dest.slice(0, -1) | ||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, {recursive: true}) | ||
const writeStream = fs.createWriteStream(`${dest}/${info.title}.mp3`) | ||
const writeStream = fs.createWriteStream(`${dest}/${clean}.mp3`) | ||
ytdl(url, {filter: "audioonly"}).pipe(writeStream) | ||
this.awaitStream(writeStream) | ||
return `${dest}/${info.title}.mp3` | ||
return `${dest}/${clean}.mp3` | ||
} | ||
@@ -209,0 +211,0 @@ |
{ | ||
"name": "youtube.ts", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Wrapper for the YouTube API with typings.", | ||
@@ -5,0 +5,0 @@ "main": "dist/youtube.js", |
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
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
156634
3300