Skip to content

Commit

Permalink
coming along well
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeaux committed Sep 17, 2020
1 parent f2fa3b9 commit eca2e3b
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 7 deletions.
14 changes: 7 additions & 7 deletions controllers/frontend/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ exports.livestreaming = async(req, res) =>

var networkInterfaces = os.networkInterfaces( );

// TODO: probably not the best way to get the ip address
const ipAddress = networkInterfaces.lo0 && networkInterfaces.lo0[0].address || networkInterfaces.eth0 && networkInterfaces.eth0[0].address;

const address = process.env.LIVESTREAM_RTMP_DOMAIN || ipAddress;
Expand Down Expand Up @@ -925,16 +926,15 @@ exports.livestreaming = async(req, res) =>
*/
exports.getImporter = (req, res) => {

const recaptchaPublicKey = process.env.RECAPTCHA_SITEKEY;

const captchaOn = process.env.RECAPTCHA_ON == 'true';

if(!req.user){
return res.redirect('/login');
}

if(req.user.channelUrl !== 'anthony'){
return res.redirect('/login');
}

res.render('account/importer', {
title: 'Create Account',
recaptchaPublicKey,
captchaOn
title: 'Importer',
});
};
14 changes: 14 additions & 0 deletions lib/uploading/importer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));
const FileType = require('file-type');
const webp = require('webp-converter');


const youtubedl = require('youtube-dl');
Expand All @@ -8,6 +10,7 @@ const Upload = require('../../models/index').Upload;
const User = require('../../models/index').User;



const requestModule = require('request');
const request = Promise.promisifyAll(requestModule);
const _ = require('lodash');
Expand Down Expand Up @@ -36,6 +39,17 @@ async function downloadAndSaveThumbnails(thumbnailUrl, uniqueTag, channelUrl, ex

await fs.writeFileAsync(thumbnailDestination, thumbnail.body, 'binary');

// TODO: test : is this webp?

// if so, have to convert that file to png via that libary
// const result = webp.dwebp(originalFile, convertedFile, "-o");

// then return the path of that file as this function

// also pass that extension

// return the extension

console.log(`THUMBNAILS SAVED LOCALLY`);

console.log(uniqueTag)
Expand Down
53 changes: 53 additions & 0 deletions lib/uploading/tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const FileType = require('file-type');
const webp = require('webp-converter');


(async () => {
const fileTypeData = await FileType.fromFile('hq1.jpg');

const extension = fileTypeData.ext;

const mime = fileTypeData.mime;

if(extension == 'webp'){
console.log('webp fo sho')
}

console.log(extension, mime);







// console.log(fileTypeData.ext);
//=> {ext: 'png', mime: 'image/png'}
});


async function main(){
const fileTypeData = await FileType.fromFile('hq2.png');

console.log(fileTypeData)
}

// main();


function convertFile(originalFile, convertedFile){
const result = webp.dwebp(originalFile, convertedFile, "-o");

result.then((response) => {
console.log(response);
});
}

const originalFile = 'hq1.jpg';
const convertedFile = 'hq2.png';

module.exports = convertFile;

// make sure convertedFile is .png
// convertFile(originalFile, convertedFile);

63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"express-useragent": "^1.0.12",
"express-validator": "^3.1.2",
"fbgraph": "^1.4.4",
"file-type": "^15.0.1",
"fluent-ffmpeg": "^2.1.2",
"forever": "^2.0.0",
"formidable": "^1.2.1",
Expand Down Expand Up @@ -116,6 +117,7 @@
"twit": "^2.2.11",
"validator": "^7.0.0",
"webhook-discord": "^3.5.1",
"webp-converter": "^2.3.0",
"winston": "^3.2.1",
"ws": "^3.3.3",
"youtube-dl": "github:mayeaux/workingyoutubedl",
Expand Down

0 comments on commit eca2e3b

Please sign in to comment.