Electron rewrite for a desktop application with download support, moved all legacy code to ./legacy/

This commit is contained in:
Holly Kyd
2018-12-23 20:29:40 +00:00
parent 3b0fdb4287
commit 12f554dc88
16 changed files with 3760 additions and 36 deletions

25
index.html Normal file
View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div id="Instructions">
<h1 id="CurrentDirectory">Currently saving videos to: <code>~/Desktop</code></h1>
Videos to record (seperate different videos by new lines):
</div>
<div id="Input">
<textarea id="VideosToRecord"></textarea>
</div>
<!-- <button id="ChangeDirectory" type="button">Video save location</button> -->
<script src="src/Events.js"></script>
<script src="src/YouTubeHelper.js"></script>
</body>
</html>

2
legacy/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

61
legacy/.gitignore vendored Normal file
View File

@@ -0,0 +1,61 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

21
legacy/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 plane000
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

6
legacy/README.md Normal file
View File

@@ -0,0 +1,6 @@
# youtube-downloader
Simple to use youtube downloader, simply fill up the text files with videos you wish to download, sepperated by lines. run `npm i` and `node index.js` to download all of the videos in the file!
# Contrubutors
- Ben (plane000)#8618 <benjaminkyd@gmail.com>

40
legacy/index.js Normal file
View File

@@ -0,0 +1,40 @@
const fs = require('fs');
const ytdl = require('ytdl-core');
let videos = [];
if (!fs.existsSync('./videos.txt')) {
console.log('Could not find videos.txt, make sure it exists and has youtube links, each on new lines');
process.exit();
}
let text = fs.readFileSync('./videos.txt').toString();
text.split('\n').forEach((line) => {
videos.push(line.replace(/\r/, ''));
});
videos.forEach((url) => {
if (ytdl.validateURL(url)) {
ytdl.getInfo(url, (err, info) => {
if (err) {
console.log(`An error occured while downloading '${url}'`)
} else {
let title = info.title;
try {
let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`));
stream.on('finish', () => console.log(`Finish downloading ${title}`));
} catch (e) {
console.log(`An error occured while downloaing '${title}' retrying`)
try {
let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`));
stream.on('finish', () => console.log(`Finished downloading '${title}'`));
} catch (e) {
console.log(`Unable to download '${title}'`)
}
}
console.log(`Downloading '${title}'`);
}
})
} else console.log(`Video ${url} was not found`);
});

47
legacy/package-lock.json generated Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "youtube-dowloader",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
},
"html-entities": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
},
"m3u8stream": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.3.0.tgz",
"integrity": "sha512-0tvjXDIa6BolPEGo9zioQiPqfQhjopZXN3L7vZH/rZQCOLd4rPXNZc1UBMdW3TRpjNBoD0+F1X41/f0iY23rlQ==",
"requires": {
"miniget": "1.2.0"
}
},
"miniget": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz",
"integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"ytdl-core": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.21.1.tgz",
"integrity": "sha512-K6ysXuHW0X3MgeLpO4IHvHp5gdF2DDrgFPP7kQODBSpeaq4+/y8lvWy6ZpxtJdQGE0+GUaBZ2H1/kYcP327UdQ==",
"requires": {
"html-entities": "1.2.1",
"m3u8stream": "0.3.0",
"miniget": "1.2.0",
"sax": "1.2.4"
}
}
}
}

15
legacy/package.json Normal file
View File

@@ -0,0 +1,15 @@
{
"name": "youtube-dowloader",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Ben (plane000)",
"license": "MIT",
"dependencies": {
"fs": "0.0.1-security",
"ytdl-core": "^0.21.1"
}
}

1
legacy/videos.txt Normal file
View File

@@ -0,0 +1 @@
https://www.youtube.com/watch?v=C00igZTktfc

37
main.js Normal file
View File

@@ -0,0 +1,37 @@
const {app, BrowserWindow} = require('electron');
require('electron-reload')(__dirname);
function createWindow() {
module.exports.window = new BrowserWindow({
width: 1000,
height: 800,
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();
}
});

3477
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,22 @@
{
"name": "youtube-dowloader",
"name": "youtube-downloader",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"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"
},
"dependencies": {
"fs": "0.0.1-security",
"ytdl-core": "^0.21.1"
"electron-reload": "^1.4.0"
}
}

BIN
resources/YouTube Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

10
src/Events.js Normal file
View File

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

6
src/YouTubeHelper.js Normal file
View File

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

31
style.css Normal file
View File

@@ -0,0 +1,31 @@
@import url('https://fonts.googleapis.com/css?family=Roboto:400,100');
@import url('https://fonts.googleapis.com/css?family=Roboto');
a {
color: inherit;
text-decoration: none;
}
body {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
padding-left: 25px;
background-size: cover;
background: rgb(249, 249, 249);
color: rgb(1, 1, 1);
font-family: 'Roboto', sans-serif;
}
code {
font-size: 90%;
font-family: Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
color: #444444;
background: #e0e0e0;
}
textarea {
resize: none;
width: 400px;
height: 100px;
}