Skip to content

Instantly share code, notes, and snippets.

@ThunderWiring
Created September 14, 2018 22:13
Show Gist options
  • Save ThunderWiring/6599ae170a3f58080aa210c4dc310a35 to your computer and use it in GitHub Desktop.
Save ThunderWiring/6599ae170a3f58080aa210c4dc310a35 to your computer and use it in GitHub Desktop.
const express = require('express');
const bodyParser = require("body-parser");
const querystring = require('querystring');
const http = require('http');
const YoutubeVideoManager = require('./src/management/youtube_video_manager.js');
const PORT = 3000;
const app = express();
const server = app.listen(PORT, '10.0.0.3');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
server.on('listening', (error) => {
if (error) {
console.error('error ancountered: ' + error);
} else {
console.log('Express server started on port %s',
server.address().port);
}
});
app.get('/', (request, response) => {
response.setHeader('Content-Type', 'text/html');
response.sendFile( __dirname + '/src/ui/home.html' );
});
app.get('/styles/home.css', (request, response) => {
const style = `${__dirname}/src/uiBundle/styles/home.css`;
response.sendFile(style);
});
app.get('/styles/linksTable.css', (request, response) => {
const style = `${__dirname}/src/uiBundle/styles/linksTable.css`;
response.sendFile(style);
});
app.get('/styles/progress.css', (request, response) => {
const style = `${__dirname}/src/uiBundle/styles/progress.css`;
response.sendFile(style);
});
app.get('/home.js', (request, response) => {
response.sendFile(__dirname + '/src/uiBundle/home.js');
});
app.get('/convert', (request, response) => {
const youtubeLinkToCovert = request.query.youtubeLink;
response.send('video converted!');
const videoManager = new YoutubeVideoManager(youtubeLinkToCovert);
videoManager.extractAudio('');
});
app.get('/get-video-title', (request, response) => {
const youtubeLink = request.query.youtubeLink;
const videoManager = new YoutubeVideoManager(youtubeLink);
videoManager.getVideoInfo().then((info) => {
response.send(info.title);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment