diff --git a/index.js b/index.js index 7120b8a..7ed79e4 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import('./src/index').main(); \ No newline at end of file +require('./src/index').Main(); diff --git a/logs.log b/logs.log new file mode 100644 index 0000000..e6d043f --- /dev/null +++ b/logs.log @@ -0,0 +1,15 @@ +[16-06-20 02:51:15] HTTP server listening on port 8080 +[16-06-20 02:51:15] WebSocket server listening on 8080 +[16-06-20 02:51:17] New socket connection from id: TSXRgqiCWne8yRn9AAAA +[16-06-20 02:51:23] HTTP server listening on port 8080 +[16-06-20 02:51:23] WebSocket server listening on 8080 +[16-06-20 02:51:23] New socket connection from id: zD5Up-p5htV05KuGAAAA +[16-06-20 02:52:18] HTTP server listening on port 8080 +[16-06-20 02:52:18] WebSocket server listening on 8080 +[16-06-20 02:52:20] New socket connection from ip: undefined +[16-06-20 02:52:24] HTTP server listening on port 8080 +[16-06-20 02:52:24] WebSocket server listening on 8080 +[16-06-20 02:52:24] New socket connection from ip: ::1 +[16-06-20 02:52:49] HTTP server listening on port 8080 +[16-06-20 02:52:49] WebSocket server listening on 8080 +[16-06-20 02:52:51] New socket connection from ip: ::1, unique id: 7W0rQzo24-UqCalpAAAA diff --git a/public/index.html b/public/index.html index e2e3dc2..daf6d59 100644 --- a/public/index.html +++ b/public/index.html @@ -1,11 +1,26 @@ - - - - - Ben's Amazing YoutTube Downloader - - - - - \ No newline at end of file + + + + + Ben's Amazing YouTube Downloader + + + + + +
+ Videos to record (seperate different videos by new lines): +
+ +
+ +
+ + + Only Download Audio (.mp3) + + + + + diff --git a/public/index.js b/public/index.js new file mode 100644 index 0000000..2c1011d --- /dev/null +++ b/public/index.js @@ -0,0 +1,5 @@ +let socket = io(); + +(() => { + console.log('Starting up'); +})(); diff --git a/legacy/public/resources/YouTube Logo.png b/public/resources/YouTube Logo.png similarity index 100% rename from legacy/public/resources/YouTube Logo.png rename to public/resources/YouTube Logo.png diff --git a/legacy/public/style.css b/public/style.css similarity index 100% rename from legacy/public/style.css rename to public/style.css diff --git a/src/config.js b/src/config.js index 976dbca..9ef9515 100644 --- a/src/config.js +++ b/src/config.js @@ -1,4 +1,12 @@ module.exports.Configuration = {} - +module.exports.Load = () => +{ + module.exports.Configuration = { + LogFile: 'logs.log', + ListenPort: 8080, + PublicDirectory: 'public', + StorageDirectory: './tmp/' + } +} diff --git a/src/downloader.js b/src/downloader.js deleted file mode 100644 index 85f0cf9..0000000 --- a/src/downloader.js +++ /dev/null @@ -1,3 +0,0 @@ -const ytdl = require('ytdl-core'); - - diff --git a/src/index.js b/src/index.js index 9c99ce9..89abc92 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,11 @@ +const Logger = require('./logger') +const Config = require('./config'); +const Server = require('./server'); - -module.exports.main = async function() +module.exports.Main = async () => { - + await Config.Load(); + + await Server.Init(); + Server.Listen(); } diff --git a/src/logger.js b/src/logger.js index 98ce516..a388c2b 100644 --- a/src/logger.js +++ b/src/logger.js @@ -1,7 +1,14 @@ -const moment = require('moment'); +const Config = require('./config') + +const Moment = require('moment'); +const fs = require('fs'); + const dateFormat = 'DD-MM-YY HH:mm:ss' -module.exports.log = function(log) { - let d = moment().format(dateFormat); - console.log('[' + d.toLocaleString() + '] ' + log); +module.exports.Log = (log) => +{ + let d = Moment().format(dateFormat); + log = '[' + d.toLocaleString() + '] ' + log; + console.log(log); + fs.appendFile(Config.Configuration.LogFile, log + '\n', (e) => { if (e) throw e; }); } diff --git a/src/server.js b/src/server.js index c4a0860..978a15c 100644 --- a/src/server.js +++ b/src/server.js @@ -1,3 +1,4 @@ +const Logger = require('./logger') const Config = require('./config'); const express = require('express'); @@ -6,24 +7,24 @@ let app; let http; let io; -module.exports.Init = async () => { +module.exports.Init = async () => +{ app = require('express')(); http = require('http').Server(app); io = require('socket.io')(http); - - http.listen(main.config.serverPort, () => { - logger.log(`HTTP server listening on port ${main.config.serverPort}`); - logger.log(`WebSocket server listening on ${main.config.serverPort}`); - }); } -module.exports.listen = async () => { - app.use(express.static('public')); +module.exports.Listen = async () => +{ + http.listen(Config.Configuration.ListenPort, () => { + Logger.Log(`HTTP server listening on port ${Config.Configuration.ListenPort}`); + Logger.Log(`WebSocket server listening on ${Config.Configuration.ListenPort}`); + }); + + app.use(express.static(Config.Configuration.PublicDirectory)); io.on('connection', async (socket) => { - logger.log(`New socket connection from id: ${socket.id}`); - - + Logger.Log(`New socket connection from ip: ${socket.handshake.address}, unique id: ${socket.id}`); }); } diff --git a/src/youtubedownloader.js b/src/youtubedownloader.js new file mode 100644 index 0000000..4892f96 --- /dev/null +++ b/src/youtubedownloader.js @@ -0,0 +1,3 @@ +const YTDL = require('ytdl-core'); + + diff --git a/src/youtubehelper.js b/src/youtubehelper.js new file mode 100644 index 0000000..2ac00fd --- /dev/null +++ b/src/youtubehelper.js @@ -0,0 +1,11 @@ +const YTDL = require('ytdl-core'); + +module.exports.GetVideoInfoArr = async (arr) => +{ + +} + +module.exports.GetVideoInfo = async (video) => +{ + +}