Compare commits
No commits in common. "2d5a089302201ed78a5a79ce2b0c8a3052e753cc" and "6fb90e6815e36bbe2b24797bd2035c6fca8cbea4" have entirely different histories.
2d5a089302
...
6fb90e6815
7 changed files with 256 additions and 564 deletions
|
@ -20,36 +20,18 @@ var audioFormats = [
|
|||
"mp3"
|
||||
]
|
||||
|
||||
expressManager.app.get("/watch", async (req, res) => {
|
||||
var html = fs.readFileSync(path.join(__dirname, "resources/playInBrowser.html")).toString()
|
||||
var finalMetadata = "?"
|
||||
for (var i in req.query) {
|
||||
if (i != "playInBrowser") {
|
||||
finalMetadata += i + "=" + req.query[i] + "&"
|
||||
}
|
||||
}
|
||||
html = html.replaceAll("{DOWNLOAD_URL}", finalMetadata)
|
||||
res.send(html)
|
||||
})
|
||||
|
||||
expressManager.app.get("/download", async (req, res) => {
|
||||
var url = req.query.url,
|
||||
quality = req.query.quality,
|
||||
format = req.query.format,
|
||||
trimAudio = req.query.trimAudio && audioFormats.includes(format) || false
|
||||
|
||||
if (req.query.playInBrowser && !audioFormats.includes(format)) {
|
||||
var metadata = req.url.substring(req.url.indexOf("?"))
|
||||
res.redirect("/watch" + metadata)
|
||||
} else if (ytdl.validateURL(url) && qualityLabels.includes(quality)) {
|
||||
if (ytdl.validateURL(url) && qualityLabels.includes(quality)) {
|
||||
var needsVideo = !audioFormats.includes(format)
|
||||
|
||||
var info = await ytdl.getInfo(url)
|
||||
|
||||
var downloadType = "attachment"
|
||||
if (req.query.playInBrowser) downloadType = "inline";
|
||||
|
||||
res.setHeader("Content-Disposition", `${downloadType}; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
|
||||
res.setHeader("Content-Disposition", `attachment; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
|
||||
|
||||
var audioFormat = ytdl.chooseFormat(info.formats, { filter: (format) => {
|
||||
return format.hasAudio && !format.hasVideo
|
||||
|
|
2
index.js
2
index.js
|
@ -1,2 +1,2 @@
|
|||
require("./express.js")
|
||||
require("./downloader.js")
|
||||
require("./downloader.js")
|
754
package-lock.json
generated
754
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/Violets-puragtory/YoutubeConverter#readme",
|
||||
"dependencies": {
|
||||
"@distube/ytdl-core": "^4.15.1",
|
||||
"@distube/ytdl-core": "^4.14.4",
|
||||
"child_process": "^1.0.2",
|
||||
"express": "^4.18.2",
|
||||
"ffmpeg-static": "^5.2.0"
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<style>
|
||||
* {
|
||||
margin: auto;
|
||||
padding: 0 !important;
|
||||
}
|
||||
body {
|
||||
width: 100vw;
|
||||
max-width: 100vw;
|
||||
padding: 0;
|
||||
background-color: black;
|
||||
}
|
||||
video {
|
||||
width: 100vw;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
</style>
|
||||
<title>Playing video in browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<video controls src="/download{DOWNLOAD_URL}"></video>
|
||||
</body>
|
||||
</html>
|
|
@ -61,12 +61,8 @@
|
|||
<!-- <input style="display: inline-block" type="checkbox" id="trim" checked>
|
||||
<p style="display: inline-block" for="trim">Trim BALLS (mp4 only)</p> -->
|
||||
</div>
|
||||
<div id="either">
|
||||
<input style="display: inline-block" type="checkbox" id="playInBrowers" name="playInBrowser">
|
||||
<p style="display: inline-block" for="trim">Play in browser</p>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Begin Download">
|
||||
<input type="submit">
|
||||
</form>
|
||||
<!-- <br> -->
|
||||
|
||||
|
|
|
@ -17,10 +17,8 @@ $(document).ready(() => {
|
|||
|
||||
$("#quality").val(Cookies.get("quality") || "720")
|
||||
$("#trim").prop("checked", Cookies.get("trim") == "true" || false)
|
||||
$("#playInBrowser").prop("checked", Cookies.get("playInBrowser") == "true" || false)
|
||||
$("form").submit(() => {
|
||||
Cookies.set("quality", $("#quality").val())
|
||||
Cookies.set("trim", $("#trim").prop("checked"))
|
||||
Cookies.set("playInBrowser", $("#playInBrowser").prop("checked"))
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue