Node rewrite as a webapp, hosted locally, at some point a react rewrite will come

This commit is contained in:
Ben
2018-12-24 12:07:12 +00:00
parent 07e2d86c1e
commit 2787cf21b3
11 changed files with 537 additions and 3355 deletions

1
index.js Normal file
View File

@@ -0,0 +1 @@
require('./src/index').main();

37
main.js
View File

@@ -1,37 +0,0 @@
const {app, BrowserWindow} = require('electron');
require('electron-reload')(__dirname);
function createWindow() {
module.exports.window = new BrowserWindow({
width: 1000,
height: 600,
isResizable: false,
resizable: false
});
module.exports.window.loadFile('index.html');
module.exports.window.openDevTools();
module.exports.window.isResizable(false);
module.exports.window.on('closed', () => {
module.exports.window = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
// MacOS is weird and an application will stay
//open until explicitly closed with command + q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (module.exports.window === null) {
createWindow();
}
});

3790
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,20 +3,16 @@
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/plane000/youtube-downloader.git"
},
"author": "Ben (plane000)",
"license": "MIT",
"devDependencies": {
"electron": "^4.0.0",
"electron-rebuild": "^1.8.2"
},
"devDependencies": {},
"dependencies": {
"electron-reload": "^1.4.0"
"express": "^4.16.4",
"socket.io": "^2.2.0",
"ytdl-core": "^0.28.3"
}
}

View File

@@ -19,7 +19,6 @@
</div>
<!-- <button id="ChangeDirectory" type="button">Video save location</button> -->
<script src="src/Events.js"></script>
<script src="src/YouTubeHelper.js"></script>
<script src="index.js"></script>
</body>
</html>
</html>

0
public/index.js Normal file
View File

View File

@@ -1,10 +0,0 @@
(() => {
console.log('STARTUP')
})();
document.getElementById('VideosToRecord').addEventListener('keydown', () => {
let videoText = document.getElementById('VideosToRecord').value;
VideosToDownload = videoText.split('\n');
console.log(VideosToDownload);
});

View File

@@ -1,6 +0,0 @@
let currentDirectory = '~/Desktop';
let VideosToDownload = [];
const fs = require('fs');
const ytdl = require('ytdl-core');

6
src/index.js Normal file
View File

@@ -0,0 +1,6 @@
const server = require('./server');
module.exports.main = async () => {
await server.init();
await server.listen();
}

25
src/server.js Normal file
View File

@@ -0,0 +1,25 @@
let app;
let http;
let io;
module.exports.init = async () => {
app = require('express')();
http = require('http').Server(app);
io = require('socket.io')(http);
http.listen(80, () => {
console.log('HTTP server listening on port 80');
console.log('Socket server listening');
});
}
module.exports.listen = async () => {
app.use()
app.get('/', (req, res) => {
res.sendFile(__dirname + '/../public/index.html');
});
}
module.exports.app = app;
module.exports.http = http;
module.exports.io = io;