mirror of
https://github.com/SrIzan10/youtubeDownloader.git
synced 2026-05-01 11:06:58 +00:00
Added mp3 support
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -10,10 +10,19 @@ app.listen(4000, () => {
|
||||
console.log('Server Works !!! At port 4000');
|
||||
});
|
||||
|
||||
app.get('/download', (req,res) => {
|
||||
var URL = req.query.URL;
|
||||
app.get('/downloadmp3', (req,res) => {
|
||||
var url = req.query.url;
|
||||
res.header('Content-Disposition', 'attachment; filename="audio.mp3"');
|
||||
ytdl(url, {
|
||||
format: 'mp3',
|
||||
filter: 'audioonly'
|
||||
}).pipe(res);
|
||||
});
|
||||
|
||||
app.get('/downloadmp4', (req,res) => {
|
||||
var url = req.query.url;
|
||||
res.header('Content-Disposition', 'attachment; filename="video.mp4"');
|
||||
ytdl(URL, {
|
||||
ytdl(url, {
|
||||
format: 'mp4'
|
||||
}).pipe(res);
|
||||
});
|
||||
785
Server/package-lock.json
generated
785
Server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
|
||||
<body>
|
||||
<h1 class="heading">My Own Youtube Downloader !</h1>
|
||||
<input class="URL-input" placeholder="https://www.youtube.com/watch?v=MtN1YnoL46Q"><button class="convert-button">Convert</button>
|
||||
<input class="URL-input" placeholder="https://www.youtube.com/watch?v=MtN1YnoL46Q"><button class="convert-button" id="mp4">Convert mp4</button><button class="convert-button" id='mp3'>Convert mp3</button>
|
||||
<script src='script.js'></script>
|
||||
</body>
|
||||
|
||||
|
||||
22
script.js
22
script.js
@@ -1,11 +1,23 @@
|
||||
var convertBtn = document.querySelector('.convert-button');
|
||||
var mp3Btn = document.getElementById('mp3');
|
||||
var mp4Btn = document.getElementById('mp4');
|
||||
var URLinput = document.querySelector('.URL-input');
|
||||
var server = 'http://localhost:4000';
|
||||
|
||||
convertBtn.addEventListener('click', () => {
|
||||
mp3Btn.addEventListener('click', () => {
|
||||
console.log(`URL: ${URLinput.value}`);
|
||||
sendURL(URLinput.value);
|
||||
redirectMp3(URLinput.value);
|
||||
});
|
||||
|
||||
function sendURL(URL) {
|
||||
window.location.href = `http://localhost:4000/download?URL=${URL}`;
|
||||
|
||||
mp4Btn.addEventListener('click', () => {
|
||||
console.log(`URL: ${URLinput.value}`);
|
||||
redirectMp4(URLinput.value);
|
||||
});
|
||||
|
||||
function redirectMp3(query) {
|
||||
window.location.href = `${server}/downloadmp3?url=${query}`;
|
||||
}
|
||||
|
||||
function redirectMp4(query) {
|
||||
window.location.href = `${server}/downloadmp4?url=${query}`;
|
||||
}
|
||||
Reference in New Issue
Block a user