Compare commits

...

3 commits

Author SHA1 Message Date
0a83662ef2 Bump version 2021-06-12 16:28:03 +02:00
97a1bdaa2c Show latest log hash 2021-06-12 16:27:56 +02:00
cef981c522 Check for video format 2021-06-12 16:27:46 +02:00
4 changed files with 111 additions and 87 deletions

View file

@ -7,6 +7,8 @@ RUN git clone https://git.namejeff.xyz/Supositware/jeff-downloader.git .
RUN git checkout progress RUN git checkout progress
RUN git log -1 --format=%h
RUN npm install RUN npm install
RUN npm i -g pm2 RUN npm i -g pm2

View file

@ -1,6 +1,6 @@
{ {
"name": "jeff-downloader2", "name": "jeff-downloader2",
"version": "0.2.0", "version": "0.3.0",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node ./bin/www" "start": "node ./bin/www"

View file

@ -80,12 +80,39 @@ router.get('/', function(req, res, next) {
router.get('/status/:uuid', function (req, res ,next) { router.get('/status/:uuid', function (req, res ,next) {
let uuid = req.params.uuid; let uuid = req.params.uuid;
if (progress[uuid]) { if (progress[uuid]) {
res.send(progress[uuid]); return res.send(progress[uuid]);
} else { } else {
res.send(undefined); return res.send(undefined);
} }
}); });
router.get('/format', function (req, res ,next) {
let url;
let i = 0;
try {
url = new URL(req.query.url);
} catch (e) {
return res.send(undefined);
}
let formats = [];
youtubedl.exec(url.href, ['--dump-json'], {}, function(err, output) {
if (err) throw err
let json = JSON.parse(output);
json.formats.forEach(format => {
if (format.vcodec === 'none' || format.acodec === 'none')
return;
i++;
formats.push({ext: format.ext, id: format.format_id, note: format.format_note});
});
return res.send(formats);
});
return;
});
router.post('/', async function(req, res, next) { router.post('/', async function(req, res, next) {
let data; let data;
const form = formidable({ multiples: true}); const form = formidable({ multiples: true});
@ -99,22 +126,17 @@ router.post('/', async function(req, res, next) {
}) })
}); });
console.log(data.url);
if (data.url === undefined) { if (data.url === undefined) {
//res.render('index', { error: true, errormsg: 'You didn\'t input a link'}) //res.render('index', { error: true, errormsg: 'You didn\'t input a link'})
return res.send('You didn\'t input a link') return res.send('You didn\'t input a link')
} }
let quality; console.log(data.format);
if (data.quality === 'worst') {
quality = 'worst';
} else {
quality = 'best';
}
if (data.format === undefined) { let format = data.format;
data.format = 'mp4';
if (data.format === undefined || data.format === 'mp3' || data.format === 'flac') {
format = 'best';
} }
if (data.url.toLowerCase().includes('porn')) { if (data.url.toLowerCase().includes('porn')) {
@ -132,7 +154,7 @@ router.post('/', async function(req, res, next) {
} }
} }
let options = ['--format=mp4', '-f', quality]; let options = ['-f', format];
if (data.proxy !== 'none') { if (data.proxy !== 'none') {
options.push('--proxy'); options.push('--proxy');
options.push(data.proxy); options.push(data.proxy);
@ -182,7 +204,28 @@ router.post('/', async function(req, res, next) {
video.on('end', function() { video.on('end', function() {
progress[data.uuid] = 0; progress[data.uuid] = 0;
if (data.format === 'mp4' || data.format === 'webm') {
if (data.format === 'mp3' || data.format === 'flac') {
// If user requested an audio format, convert it
ffmpeg(`./public/uploads/${DLFile}`)
.noVideo()
.audioChannels('2')
.audioFrequency('44100')
.audioBitrate('320k')
.format(data.format)
.save(`./public/uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`)
.on('error', function(err, stdout, stderr) {
console.log('Cannot process video: ' + err.message);
return res.json({error: err.message});
//return res.render('index', { error: true, errormsg: err.message})
})
.on('end', () => {
fs.unlinkSync(`./public/uploads/${DLFile}`);
if (data.feed !== 'on') generateWaveform(DLFile.replace(`.${ext}`, `.${data.format}`));
return res.json({url: `uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`});
//return res.attachment(`./public/uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`);
});
} else {
if (data.sponsorBlock) { // WARNING: THIS PART SUCK if (data.sponsorBlock) { // WARNING: THIS PART SUCK
let filter = ''; let filter = '';
let abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; let abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
@ -246,26 +289,6 @@ router.post('/', async function(req, res, next) {
res.json({url: `uploads/${DLFile}`}) res.json({url: `uploads/${DLFile}`})
if (data.feed !== 'on') generateThumbnail(DLFile); if (data.feed !== 'on') generateThumbnail(DLFile);
} }
} else {
// If user requested an audio format, convert it
ffmpeg(`./public/uploads/${DLFile}`)
.noVideo()
.audioChannels('2')
.audioFrequency('44100')
.audioBitrate('320k')
.format(data.format)
.save(`./public/uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`)
.on('error', function(err, stdout, stderr) {
console.log('Cannot process video: ' + err.message);
return res.json({error: err.message});
//return res.render('index', { error: true, errormsg: err.message})
})
.on('end', () => {
fs.unlinkSync(`./public/uploads/${DLFile}`);
if (data.feed !== 'on') generateWaveform(DLFile.replace(`.${ext}`, `.${data.format}`));
return res.json({url: `uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`});
//return res.attachment(`./public/uploads/${DLFile.replace(`.${ext}`, `.${data.format}`)}`);
});
} }
}); });

View file

@ -4,7 +4,7 @@ I guess have fun looking at the html, no easter egg to find here.
Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for all my bad coding Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for all my bad coding
--> -->
<!DOCTYPE html> <!DOCTYPE html>
<html class="gradientBG" lang="en"> <html class="has-background-grey-dark" lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -24,18 +24,6 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
<title>Le epic video downloader v<%= version %></title> <title>Le epic video downloader v<%= version %></title>
</head> </head>
<body class="has-text-light gradientBG"> <body class="has-text-light gradientBG">
<ul class="circles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<section class="section has-text-centered"> <section class="section has-text-centered">
<div class="container"> <div class="container">
<h1 class="title has-text-light">Le epic downloader v<%= version %></h1> <h1 class="title has-text-light">Le epic downloader v<%= version %></h1>
@ -45,21 +33,6 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
<div class="field-body"> <div class="field-body">
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="control"> <div class="control">
<label class="radio" for="small">
<input class="radio" type="radio" name="quality" id="small" value="small">
Low quality
</label>
<label class="radio" for="high">
<input class="radio" type="radio" name="quality" id="high" value="high" checked>
High quality
</label>
<label class="checkbox" for="alt">
<input class="checkbox" type="checkbox" name="alt" id="alt" title="Use this if download dosen't work">
Alternate download
</label>
<label class="checkbox" for="feed"> <label class="checkbox" for="feed">
<input class="checkbox" type="checkbox" name="feed" id="feed" title="Use this if you don't want the video you are downloading to be public"> <input class="checkbox" type="checkbox" name="feed" id="feed" title="Use this if you don't want the video you are downloading to be public">
Hide from feed Hide from feed
@ -78,8 +51,17 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
<div class="field-body"> <div class="field-body">
<div class="field is-expanded"> <div class="field is-expanded">
<div class="field has-addons"> <div class="field has-addons">
<p class="control">
<div class="select">
<select name="format" id="format">
<option value="mp4">MP4</option>
<option value="mp3">MP3</option>
<option value="flac">FLAC</option>
</select>
</div>
</p>
<p class="control is-expanded"> <p class="control is-expanded">
<input type="text" id="url" name="url" class="downloadurl input is-rounded" placeholder="Link"> <input type="text" id="url" name="url" class="downloadurl input is-rounded" placeholder="Link" onkeyup="CheckFormat()">
</p> </p>
<p class="control"> <p class="control">
<button type="submit" class="downloadbtn button is-primary is-rounded" id="button">Download that mf video</button> <button type="submit" class="downloadbtn button is-primary is-rounded" id="button">Download that mf video</button>
@ -97,25 +79,7 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
</div> </div>
<div class="field is-horizontal level"> <div class="field is-horizontal level">
<div class="field-body">
<div class="control level-left">
<label class="radio" for="mp4">
<input class="radio" type="radio" name="format" value="mp4" id="mp4" checked>
Video?
</label>
<label class="radio" for="mp3">
<input class="radio" type="radio" name="format" value="mp3" id="mp3">
MP3?
</label>
<label class="radio" for="flac" title="This is pure placebo">
<input class="radio" type="radio" name="format" value="flac" id="flac" title="This is pure placebo">
FLAC?
</label>
</div>
<div class="field-body level-right">
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="control"> <div class="control">
<span>Proxy options:</span> <span>Proxy options:</span>
@ -216,13 +180,11 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
document.getElementById('progress').innerHTML = '<progress class="progress is-success" id="progress-bar" max="100">0%</progress>'; document.getElementById('progress').innerHTML = '<progress class="progress is-success" id="progress-bar" max="100">0%</progress>';
let frm = new FormData(form); let frm = new FormData(form);
frm.append('uuid', uuid); frm.append('uuid', uuid);
console.log(...frm);
let xhttp = new XMLHttpRequest(); let xhttp = new XMLHttpRequest();
console.log('hi');
let progress = setInterval(() => { let progress = setInterval(() => {
CheckProgress(); CheckProgress();
}, 1000); }, 2000);
xhttp.addEventListener("load", function(event) { xhttp.addEventListener("load", function(event) {
const json = JSON.parse(event.target.responseText); const json = JSON.parse(event.target.responseText);
@ -280,6 +242,43 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a
}); });
} }
function CheckFormat() {
let url;
try {
url = new URL(document.getElementById("url").value);
} catch (e) {
return;
}
document.getElementsByClassName("select")[0].className = "select is-loading";
console.log(encodeURI(url.href));
let xhttp = new XMLHttpRequest();
xhttp.open("get", `/format?url=${url.href}`, true);
xhttp.send();
xhttp.addEventListener("load", function(event) {
console.log(event.target.responseText);
let html = [];
let json = JSON.parse(event.target.responseText);
json.forEach(format => {
html.push(`<option value="${format.id}">${format.ext} - ${format.note}</option>`);
});
html.reverse();
html.push('<option value="mp3">MP3</option>');
html.push('<option value="flac">FLAC</option>');
document.getElementById("format").innerHTML = html;
document.getElementsByClassName("select")[0].className = "select";
});
xhttp.addEventListener("error", function(event) {
console.error(event.target.responseText);
});
}
function uuidv4() { function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);