Experimental update

expect some formats to not work
This commit is contained in:
Violet 2023-08-21 16:46:48 +00:00
parent bb72eff5cc
commit 94ebbfba18
5 changed files with 87 additions and 25 deletions

View file

@ -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 # 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.

View file

@ -1,7 +1,8 @@
const ytdl = require('ytdl-core') const ytdl = require('ytdl-core'),
const fs = require('fs') fs = require('fs'),
const path = require('path') path = require('path'),
const express = require('express') express = require('express'),
ffmpeg = require('fluent-ffmpeg')
const PORT = process.env.PORT || 8080 const PORT = process.env.PORT || 8080
const app = express() const app = express()
@ -12,8 +13,17 @@ app.get("/download", (req, res) => {
const format = req.query.format const format = req.query.format
const quality = req.query.quality const quality = req.query.quality
res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`); if (format != "mp4" && format != "webm") {
ytdl(url, { 'format': format, 'quality': quality }).pipe(res); 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);
}
}); });

42
package-lock.json generated
View file

@ -10,7 +10,8 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"express": "^4.18.2", "express": "^4.18.2",
"ytdl-core": "^4.11.4" "fluent-ffmpeg": "^2.1.2",
"ytdl-core": "^4.11.5"
} }
}, },
"node_modules/accepts": { "node_modules/accepts": {
@ -30,6 +31,11 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" "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": { "node_modules/body-parser": {
"version": "1.20.1", "version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
@ -214,6 +220,18 @@
"node": ">= 0.8" "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": { "node_modules/forwarded": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@ -309,6 +327,11 @@
"node": ">= 0.10" "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": { "node_modules/m3u8stream": {
"version": "0.8.6", "version": "0.8.6",
"resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.8.6.tgz", "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.8.6.tgz",
@ -614,10 +637,21 @@
"node": ">= 0.8" "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": { "node_modules/ytdl-core": {
"version": "4.11.4", "version": "4.11.5",
"resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.4.tgz", "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.5.tgz",
"integrity": "sha512-tsVvqt++B5LSTMnCKQb4H/PFBewKj7gGPJ6KIM5gOFGMKNZj4qglGAl4QGFG8cNPP6wY54P80FDID5eN2di0GQ==", "integrity": "sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA==",
"dependencies": { "dependencies": {
"m3u8stream": "^0.8.6", "m3u8stream": "^0.8.6",
"miniget": "^4.2.2", "miniget": "^4.2.2",

View file

@ -24,6 +24,7 @@
"homepage": "https://github.com/Violets-puragtory/YoutubeConverter#readme", "homepage": "https://github.com/Violets-puragtory/YoutubeConverter#readme",
"dependencies": { "dependencies": {
"express": "^4.18.2", "express": "^4.18.2",
"ytdl-core": "^4.11.4" "fluent-ffmpeg": "^2.1.2",
"ytdl-core": "^4.11.5"
} }
} }

View file

@ -6,9 +6,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" <!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script> crossorigin="anonymous"></script> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="./style.css"> <link rel="stylesheet" href="./style.css">
@ -34,21 +34,25 @@
<option value="lowest">Lowest</option> <option value="lowest">Lowest</option>
</select> </select>
<p>Filename:</p> <p>Filename:</p>
<input id="filename" placeholder="Enter filename" name="filename"><br> <input required id="filename" placeholder="Enter filename" name="filename"><br>
<p>Format:</p> <p>Format:</p>
<select required id="format" name="format"> <select required id="format" name="format">
<option value="mp4">.mp4</option> <option disabled>Video Options</option>
<option value="wmv">.wmv</option> <option value="mp4">.mp4 (reccommended *)</option>
<option value="webm">.webm (recommended *)</option>
<option value="flv">.flv</option> <option value="flv">.flv</option>
<option value="avi">.avi</option> <option value="avi">.avi</option>
<option value="mpeg">.mpeg</option>
<option disabled>Audio Options</option>
<option value="wmv">.wmv</option>
<option value="mp3">.mp3</option> <option value="mp3">.mp3</option>
<option value="mpg">.mpg</option>
</select> </select>
<input type="submit" placeholder="test"> <input type="submit" placeholder="test">
</form> </form>
<p>* 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.</p>
<hr> <hr>
<p>Thank you, <a>please consider donating</a> so that I may pay for hosting costs! (Or, you may also help me out by <!-- <p><a>Please consider donating</a> or host the website yourself! (Check github below for more info)</p><br> -->
hosting it <em>yourself</em> instead of using this site! (Check github for more details)</p><br> <p>Please consider hosting the project yourself! (Check github for more details)</p>
<p>Check out the <a id="github" href="https://github.com/Violets-puragtory/YoutubeConverter">Github page</a> to <p>Check out the <a id="github" href="https://github.com/Violets-puragtory/YoutubeConverter">Github page</a> to
learn how to host it yourself, how it works, report bugs, and more.</p> learn how to host it yourself, how it works, report bugs, and more.</p>
</body> </body>