diff --git a/README.md b/README.md index 1e5d101..c7eddd8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,20 @@ -# This Repository is no longer being actively developed -Due to a combination of burnout, school, stress, etc.. I have not the time nor motivation to continue working on this project. Incase I do plan to work on it in the future, or somebody wants to use my buggy, messy code, I am keeping it as a public archive. - -___ - # YoutubeConverter -A web youtube converter for converting videos to mp4, mp3, and other supported formats + +A web youtube converter for converting and downloading youtube videos to mp4, mp3, and other supported formats. + +# Dependancies + +- ffmpeg +## NodeJS Dependancies + +- fluent-ffmpeg +- express +- ytdl-core + +# Supported formats + +Downloading mp4s & webms will give the fastest download, as they are downloaded directly from youtube. However, if you wish to use a different format, it will automatically convert the video to your preffered format. + +# Supported Websites + +Currently only supports youtube. May support other sites soon. \ No newline at end of file diff --git a/index.js b/index.js index 446003c..b3735e3 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ -const ytdl = require('ytdl-core') -const fs = require('fs') -const path = require('path') -const express = require('express') +const ytdl = require('ytdl-core'), + fs = require('fs'), + path = require('path'), + express = require('express'), + ffmpeg = require('fluent-ffmpeg') const PORT = process.env.PORT || 8080 const app = express() @@ -12,8 +13,17 @@ app.get("/download", (req, res) => { const format = req.query.format const quality = req.query.quality - res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`); - ytdl(url, { 'format': format, 'quality': quality }).pipe(res); + if (format != "mp4" && format != "webm") { + var proc = new ffmpeg({ source: ytdl(url, { 'quality': quality })}) + .format(format) + .pipe(res) + + res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`); + + } else { + res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`); + ytdl(url, { 'format': format, 'quality': quality }).pipe(res); + } }); diff --git a/package-lock.json b/package-lock.json index bcd652f..a13ef8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "MIT", "dependencies": { "express": "^4.18.2", - "ytdl-core": "^4.11.4" + "fluent-ffmpeg": "^2.1.2", + "ytdl-core": "^4.11.5" } }, "node_modules/accepts": { @@ -30,6 +31,11 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, + "node_modules/async": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -214,6 +220,18 @@ "node": ">= 0.8" } }, + "node_modules/fluent-ffmpeg": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz", + "integrity": "sha512-IZTB4kq5GK0DPp7sGQ0q/BWurGHffRtQQwVkiqDgeO6wYJLLV5ZhgNOQ65loZxxuPMKZKZcICCUnaGtlxBiR0Q==", + "dependencies": { + "async": ">=0.2.9", + "which": "^1.1.1" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -309,6 +327,11 @@ "node": ">= 0.10" } }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, "node_modules/m3u8stream": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.8.6.tgz", @@ -614,10 +637,21 @@ "node": ">= 0.8" } }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, "node_modules/ytdl-core": { - "version": "4.11.4", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.4.tgz", - "integrity": "sha512-tsVvqt++B5LSTMnCKQb4H/PFBewKj7gGPJ6KIM5gOFGMKNZj4qglGAl4QGFG8cNPP6wY54P80FDID5eN2di0GQ==", + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.5.tgz", + "integrity": "sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA==", "dependencies": { "m3u8stream": "^0.8.6", "miniget": "^4.2.2", diff --git a/package.json b/package.json index 11b8293..48e52e3 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "homepage": "https://github.com/Violets-puragtory/YoutubeConverter#readme", "dependencies": { "express": "^4.18.2", - "ytdl-core": "^4.11.4" + "fluent-ffmpeg": "^2.1.2", + "ytdl-core": "^4.11.5" } } diff --git a/static/index.html b/static/index.html index d365710..cae3cb7 100644 --- a/static/index.html +++ b/static/index.html @@ -6,9 +6,9 @@ - + crossorigin="anonymous"> --> @@ -34,21 +34,25 @@

Filename:

-
+

Format:

+

* using mp4s (or webms) are highly reccomended, as those are the default formats for youtube. Any other format will require converting the video. This not only means you have to wait longer for the video to convert, which can take time depending on how many people are active, but also puts unnecessary stress on the server.


-

Thank you, please consider donating so that I may pay for hosting costs! (Or, you may also help me out by - hosting it yourself instead of using this site! (Check github for more details)


+ +

Please consider hosting the project yourself! (Check github for more details)

Check out the Github page to learn how to host it yourself, how it works, report bugs, and more.