New option to play videos in browser

This commit is contained in:
bingus_violet 2024-11-06 18:51:46 -06:00
parent a688a6293f
commit a949591f99
2 changed files with 8 additions and 1 deletions

View file

@ -31,7 +31,10 @@ expressManager.app.get("/download", async (req, res) => {
var info = await ytdl.getInfo(url)
res.setHeader("Content-Disposition", `attachment; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
var downloadType = "attachment"
if (req.query.playInBrowser) downloadType = "inline";
res.setHeader("Content-Disposition", `${downloadType}; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
var audioFormat = ytdl.chooseFormat(info.formats, { filter: (format) => {
return format.hasAudio && !format.hasVideo

View file

@ -61,6 +61,10 @@
<!-- <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">
</form>