This commit is contained in:
Theenoro 2017-10-08 23:21:55 +02:00
parent 6a3d4820c1
commit c569c0beca
15 changed files with 611 additions and 558 deletions

View File

@ -1,4 +1,4 @@
const shared = require(global.__dirname+'/../js/shared'); const shared = require(global.__dirname + '/../js/shared');
$(function() { $(function() {
const Config = require('electron-config'); const Config = require('electron-config');
const config = new Config(); const config = new Config();
@ -8,11 +8,11 @@ $(function() {
var download_progress = $('#download-progress'); var download_progress = $('#download-progress');
var format = "mp3"; var format = "mp3";
if(typeof config.get('format') !== 'undefined'){ if (typeof config.get('format') !== 'undefined') {
format = config.get('format'); format = config.get('format');
} }
var path = ""; var path = "";
if(typeof config.get('path') !== 'undefined'){ if (typeof config.get('path') !== 'undefined') {
path = config.get('path'); path = config.get('path');
} }
var out = $('#output'); var out = $('#output');
@ -23,11 +23,11 @@ $(function() {
const helperx = require('./../../controller/webLoader/router'); const helperx = require('./../../controller/webLoader/router');
var shell = require('electron').shell; var shell = require('electron').shell;
//open links externally by default //open links externally by default
$(document).on('click', 'a[href^="http"]', function(event) { $(document).on('click', 'a[href^="http"]', function(event) {
event.preventDefault(); event.preventDefault();
shell.openExternal(this.href); shell.openExternal(this.href);
}); });
const { const {
dialog dialog
@ -94,7 +94,7 @@ $(function() {
}); });
} }
}) })
$('body').delegate('#navigota li','click',function(){ $('body').delegate('#navigota li', 'click', function() {
console.log('TEST') console.log('TEST')
$('#togmenu').click(); $('#togmenu').click();
}) })
@ -148,7 +148,17 @@ $(function() {
var YT = JSON.parse(body); var YT = JSON.parse(body);
$( $(
`<div class="media"> `<div class="media">
<img id="img-` + video_id + `" class="d-flex align-self-start mr-3" src="`+ YT.thumbnail_url +`" alt="Generic placeholder image"> <div class="d-flex alogn-self-start mr-3" style="
background:url(` + YT.thumbnail_url + `);
width: 189px;
height: 104px;
background-size: 189px;
background-position: 0px -18px;
">
<div class="media-out-` + video_id + `" style=" color: #FFF !important;
text-shadow: #454545 1px 1px 1px;
margin: auto;"></div>
</div>
<div class="media-body" id="body-` + video_id + `"> <div class="media-body" id="body-` + video_id + `">
<h5 class="mt-0">` + YT.title + `</h5> <h5 class="mt-0">` + YT.title + `</h5>
Author: ` + YT.author_name + ` Author: ` + YT.author_name + `
@ -170,9 +180,9 @@ $(function() {
.get('https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=' + video_id + '&format=json', function(err, httpResponse, body) { .get('https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=' + video_id + '&format=json', function(err, httpResponse, body) {
var YT = JSON.parse(body); var YT = JSON.parse(body);
$( $(
`<div class="media"> `<div class="media">
<div class="d-flex alogn-self-start mr-3" style=" <div class="d-flex alogn-self-start mr-3" style="
background:url(`+YT.thumbnail_url+`); background:url(` + YT.thumbnail_url + `);
width: 189px; width: 189px;
height: 104px; height: 104px;
background-size: 189px; background-size: 189px;
@ -192,11 +202,12 @@ $(function() {
</div>` </div>`
).prependTo('#output'); ).prependTo('#output');
cache[video_id] = YT.title; cache[video_id] = YT.title;
ipcRenderer.send('start-download', { ipcRenderer.send('start-download', {
url: $('#url').val(), url: $('#url').val(),
id: video_id id: video_id,
title: helper.replace(YT.title)
}); });
}) })
} }
@ -214,11 +225,15 @@ $(function() {
}) })
function getCommandLine() { function getCommandLine() {
switch (process.platform) { switch (process.platform) {
case 'darwin' : return 'open'; case 'darwin':
case 'win32' : return 'start'; return 'open';
case 'win64' : return 'start'; case 'win32':
default : return 'xdg-open'; return 'start';
} case 'win64':
return 'start';
default:
return 'xdg-open';
}
} }
}) })

View File

@ -14,192 +14,194 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title></title> <title></title>
<style> <style>
body { body {
margin: 0; margin: 0;
background: #333; background: #333;
} }
@keyframes arrow-spin { @keyframes arrow-spin {
100% { 100% {
transform: rotate(179deg); transform: rotate(179deg);
} }
} }
@-webkit-keyframes arrow-spin { @-webkit-keyframes arrow-spin {
100% { 100% {
-webkit-transform: rotate(179deg); -webkit-transform: rotate(179deg);
} }
} }
.psoload, .psoload,
.psoload *, .psoload *,
.psoload *:before, .psoload *:before,
.psoload *:after { .psoload *:after {
box-sizing: border-box; box-sizing: border-box;
transition: all 0.3s; transition: all 0.3s;
-webkit-transition: all 0.3s; -webkit-transition: all 0.3s;
} }
.psoload { .psoload {
position: relative; position: relative;
margin: 30px auto; margin: 30px auto;
height: 150px; height: 150px;
width: 150px; width: 150px;
} }
.psoload .straight, .psoload .straight,
.psoload .curve { .psoload .curve {
position: absolute; position: absolute;
top: 17.5%; top: 17.5%;
left: 17.5%; left: 17.5%;
width: 65%; width: 65%;
height: 65%; height: 65%;
border-radius: 100%; border-radius: 100%;
animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite; animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite;
-webkit-animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite; -webkit-animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite;
} }
.psoload .straight:before, .psoload .straight:before,
.psoload .straight:after { .psoload .straight:after {
content: ''; content: '';
position: absolute; position: absolute;
width: 15%; width: 15%;
border-bottom: 3px solid #eee; border-bottom: 3px solid #eee;
transform: rotate(45deg); transform: rotate(45deg);
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
} }
.psoload .straight:before { .psoload .straight:before {
top: 5px; top: 5px;
left: 5px; left: 5px;
} }
.psoload .straight:after { .psoload .straight:after {
bottom: 5px; bottom: 5px;
right: 5px; right: 5px;
} }
.psoload .curve:before, .psoload .curve:before,
.psoload .curve:after { .psoload .curve:after {
content: ''; content: '';
position: absolute; position: absolute;
width: 45px; width: 45px;
height: 10px; height: 10px;
border: solid 3px transparent; border: solid 3px transparent;
border-top-color: #eee; border-top-color: #eee;
border-radius: 50%/10px 10px 0 0; border-radius: 50%/10px 10px 0 0;
z-index: 90001; z-index: 90001;
} }
.psoload .curve:before { .psoload .curve:before {
transform: rotate(-63deg) translateX(-27px) translateY(-4px); transform: rotate(-63deg) translateX(-27px) translateY(-4px);
-webkit-transform: rotate(-63deg) translateX(-27px) translateY(-4px); -webkit-transform: rotate(-63deg) translateX(-27px) translateY(-4px);
} }
.psoload .curve:after { .psoload .curve:after {
bottom: 5px; bottom: 5px;
right: 5px; right: 5px;
transform: rotate(115deg) translateX(-26px) translateY(-12px); transform: rotate(115deg) translateX(-26px) translateY(-12px);
-webkit-transform: rotate(115deg) translateX(-26px) translateY(-12px); -webkit-transform: rotate(115deg) translateX(-26px) translateY(-12px);
} }
.psoload .center { .psoload .center {
position: absolute; position: absolute;
top: 20%; top: 20%;
left: 20%; left: 20%;
width: 60%; width: 60%;
height: 60%; height: 60%;
border-radius: 100%; border-radius: 100%;
border: 3px solid #eee; border: 3px solid #eee;
} }
.psoload .inner { .psoload .inner {
position: absolute; position: absolute;
top: 25%; top: 25%;
left: 25%; left: 25%;
width: 50%; width: 50%;
height: 50%; height: 50%;
border-radius: 100%; border-radius: 100%;
animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite reverse; animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite reverse;
-webkit-animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite reverse; -webkit-animation: arrow-spin 0.85s cubic-bezier(0.2, 0.8, 0.9, 0.1) infinite reverse;
} }
.psoload .inner:before, .psoload .inner:before,
.psoload .inner:after { .psoload .inner:after {
content: ''; content: '';
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 6px solid transparent;
border-bottom-width: 11px; border-bottom-width: 11px;
border-bottom-color: #eee; border-bottom-color: #eee;
} }
.psoload .inner:before { .psoload .inner:before {
top: 12px; top: 12px;
left: 12px; left: 12px;
transform: rotate(128deg); transform: rotate(128deg);
-webkit-transform: rotate(128deg); -webkit-transform: rotate(128deg);
} }
.psoload .inner:after { .psoload .inner:after {
bottom: 12px; bottom: 12px;
right: 12px; right: 12px;
transform: rotate(-48deg); transform: rotate(-48deg);
-webkit-transform: rotate(-48deg); -webkit-transform: rotate(-48deg);
} }
.progress{
height:10px;
}
.progress .progress-bar{
height:5px;
width:30px;
background-color:#FFF;
content:"";
} .progress {
height: 10px;
}
.progress .progress-bar {
height: 5px;
width: 30px;
background-color: #FFF;
content: "";
}
</style> </style>
</head> </head>
<body> <body>
<div class="psoload"> <div class="psoload">
<div class="straight"></div> <div class="straight"></div>
<div class="curve"></div> <div class="curve"></div>
<div class="center"></div> <div class="center"></div>
<div class="inner"></div> <div class="inner"></div>
</div> </div>
<iframe id="coub" src="https://coub.com/embed/ulak9?muted=false&autostart=true&originalSize=false&startWithHD=false" allowfullscreen="true" frameborder="0" width="320" height="180"></iframe><script async src="https://c-cdn.coub.com/embed-runner.js"></script> <iframe id="coub" src="https://coub.com/embed/ulak9?muted=false&autostart=true&originalSize=false&startWithHD=false" allowfullscreen="true" frameborder="0" width="320" height="180"></iframe>
<script async src="https://c-cdn.coub.com/embed-runner.js"></script>
<hr/> <hr/>
<div class="progress"> <div class="progress">
<div class="progress-bar" id="main"></div> <div class="progress-bar" id="main"></div>
<div class="progress-bar" id="single"></div> <div class="progress-bar" id="single"></div>
</div> </div>
<script> <script>
$(function(){ $(function() {
var start = [ var start = [
"whbex", "whbex",
"wf0jb", "wf0jb",
"ulak9", "ulak9",
"wcmxa", "wc5e2",
"wc5e2" "xza2z"
]; ];
var x = Math.floor(Math.random()*start.length) var x = Math.floor(Math.random() * start.length)
$('#coub').attr('src','https://coub.com/embed/'+start[x]+'?muted=false&autostart=true&originalSize=false&startWithHD=false') $('#coub').attr('src', 'https://coub.com/embed/' + start[x] + '?muted=false&autostart=true&originalSize=false&startWithHD=false')
const ipcRenderer = require('electron').ipcRenderer; const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('download-lib', {}); ipcRenderer.send('download-lib', {});
ipcRenderer.on('progress', function(event, arg) { ipcRenderer.on('progress', function(event, arg) {
console.log(arg); // prints "pong" console.log(arg); // prints "pong"
$('#single').css("width",arg.percent+"%"); $('#single').css("width", arg.percent + "%");
}).on('fin-loading',function(event,arg){ }).on('fin-loading', function(event, arg) {
$('#main').css("width","100%"); $('#main').css("width", "100%");
setTimeout(function(){ setTimeout(function() {
ipcRenderer.send('start-full', {}); ipcRenderer.send('start-full', {});
},1000) }, 1000)
}) })
}) })
</script> </script>
</body> </body>
</html> </html>

View File

@ -8,19 +8,14 @@
module = undefined; module = undefined;
} }
</script> </script>
<!--<script src="./../libs/jquery/jquery-3.2.1.min.js"></script>
<script src="./../libs/bootstrap/js/bootstrap.js"></script>-->
<script src="./../libs/jquery/jquery-3.2.1.min.js"></script> <script src="./../libs/jquery/jquery-3.2.1.min.js"></script>
<script src="./../libs/popper.min.js"></script> <script src="./../libs/popper.min.js"></script>
<script src="./../libs/bootstrap/bootstrap.min.js"></script> <script src="./../libs/bootstrap/bootstrap.min.js"></script>
<script src="./../js/player.js"></script> <script src="./../js/player.js"></script>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Cyb3r Downloader</title> <title>Cyb3r Downloader</title>
<!--<link rel="stylesheet" href="./../libs/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="./../libs/bootstrap/css/bootstrap-theme.css" />-->
<link rel="stylesheet" href="./../libs/bootstrap/bootstrap.min.css"> <link rel="stylesheet" href="./../libs/bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="./../libs/font-awesome/css/font-awesome.min.css" /> <link rel="stylesheet" href="./../libs/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="./../style/bootstrap.min.css" /> <link rel="stylesheet" href="./../style/bootstrap.min.css" />
<link rel="stylesheet" href="./../style/style.css" /> <link rel="stylesheet" href="./../style/style.css" />
<link rel="stylesheet" href="./../style/player.css" /> <link rel="stylesheet" href="./../style/player.css" />
@ -144,17 +139,16 @@
</div> </div>
<script> <script>
$(function(){ $(function(){
require('remote').getCurrentWindow().toggleDevTools();
const webview = document.querySelector('webview') const webview = document.querySelector('webview')
const indicator = document.querySelector('.indicator') const indicator = document.querySelector('.indicator')
const loadstart = () => { const loadstart = () => {
console.log('LEL');
} }
const loadstop = () => { const loadstop = () => {
$('#webview-url').val(webview.getURL()); $('#webview-url').val(webview.getURL());
console.log('stop');
} }
$('#webviewload').click(()=>{ $('#webviewload').click(()=>{
var url = $('#webview-url').val(); var url = $('#webview-url').val();
@ -177,6 +171,23 @@
<div class="col-md-12"> <div class="col-md-12">
<h1>Info</h1> <h1>Info</h1>
<a href="https://git.tooru.thee.moe/theenoro/electron-simple-youtube-downloader" target="_blank">Git</a> <a href="https://git.tooru.thee.moe/theenoro/electron-simple-youtube-downloader" target="_blank">Git</a>
<div id="rss">
</div>
<script>
/*
$(()=>{
$.get( "https://git.tooru.thee.moe/theenoro/electron-simple-youtube-downloader/commits/master?format=atom", function( data ) {
$xml = $( data ),
$title = $xml.find( "title" );
console.log($xml)
$('#rss').html(data.toString());
alert( "Load was performed." );
});
})
*/
</script>
</div> </div>
</div> </div>
@ -194,9 +205,10 @@
</div> </div>
<script src="./../js/app.js"></script> <script src="./../js/app.js"></script>
<script> <script>
document.addEventListener("keydown", function(e) { document.addEventListener("keydown", function(e) {
if (e.which === 123) { if (e.which === 123) {
require('remote').getCurrentWindow().toggleDevTools();
} else if (e.which === 116) { } else if (e.which === 116) {
location.reload(); location.reload();
} }

View File

@ -1,4 +1,5 @@
var request = require('request'); const request = require('request');
request('https://vivo.sx/76aa530aac', function(error, response, body) { request('https://vivo.sx/76aa530aac', function(error, response, body) {
console.log('error:', error); // Print the error if one occurred console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received

View File

@ -7,20 +7,20 @@ const fs = require('fs');
var crunch = {}; var crunch = {};
crunch.session_save = (session)=>{ crunch.session_save = (session) => {
var net = `# Netscape HTTP Cookie File\n var net = `# Netscape HTTP Cookie File\n
# http://curl.haxx.se/rfc/cookie_spec.html\n # http://curl.haxx.se/rfc/cookie_spec.html\n
# This is a generated file! Do not edit.\n\n`; # This is a generated file! Do not edit.\n\n`;
var old_exp = 0; var old_exp = 0;
for(var i = 0;i<session.length;i++){ for (var i = 0; i < session.length; i++) {
if(typeof session[i].expirationDate == 'undefined'){ if (typeof session[i].expirationDate == 'undefined') {
session[i].expirationDate = old_exp; session[i].expirationDate = old_exp;
} }
if(session[i].expirationDate>old_exp){ if (session[i].expirationDate > old_exp) {
old_exp = session[i].expirationDate; old_exp = session[i].expirationDate;
} }
net += session[i].domain+' '+session[i].httpOnly.toString().toUpperCase()+' '+session[i].path+' '+session[i].secure.toString().toUpperCase()+' '+Math.ceil(session[i].expirationDate)+' '+session[i].name+' '+session[i].value+'\n'; net += session[i].domain + ' ' + session[i].httpOnly.toString().toUpperCase() + ' ' + session[i].path + ' ' + session[i].secure.toString().toUpperCase() + ' ' + Math.ceil(session[i].expirationDate) + ' ' + session[i].name + ' ' + session[i].value + '\n';
} }
//console.log(net); //console.log(net);
/*fs.writeFile(global.dir+"/tmp/c", net, function(err) { /*fs.writeFile(global.dir+"/tmp/c", net, function(err) {

View File

@ -1,126 +1,128 @@
const request = require('request'); const request = require('request');
const fs = require('fs') const fs = require('fs')
const ipcMain = require('electron').ipcMain; const ipcMain = require('electron').ipcMain;
const unzip = require('unzip'); const unzip = require('unzip');
const { spawn } = require('child_process'); const {
spawn
} = require('child_process');
var libsx = { var libsx = {
"ffmpeg":"ffmpeg", "ffmpeg": "ffmpeg",
"ffplay":"ffplay", "ffplay": "ffplay",
"ffprobe":"ffprobe", "ffprobe": "ffprobe",
"youtube-dl":"youtube-dl" "youtube-dl": "youtube-dl"
} }
var libs = {}; var libs = {};
libs.listen = null; libs.listen = null;
libs.libs = null; libs.libs = null;
ipcMain ipcMain
.on('download-lib', (event, arg)=>{ .on('download-lib', (event, arg) => {
console.log('TEST') console.log('TEST')
libs.listen = event; libs.listen = event;
console.log(`This platform is ${process.platform}`); console.log(`This platform is ${process.platform}`);
switch (process.platform) { switch (process.platform) {
case "win32": case "win32":
for (var lib in libsx) { for (var lib in libsx) {
libsx[lib] = libsx[lib]+'.exe'; libsx[lib] = libsx[lib] + '.exe';
}
break;
default:
}
for (var lib in libsx) {
if (fs.existsSync(global.dir+"/lib/"+libsx[lib])) {
}else{
libsx[lib] = null;
}
}
libs.libs = libsx;
if(libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null ){
var z = 0;
var url = libs.ff(process.platform);
if(url === ''){
libs.checkNext('youtube-dl');
}else{
switch(process.platform){
case "win32":
libs.download(url,"ffmpeg",function(data,file){
fs.createReadStream(file)
.pipe(unzip.Parse())
.on('entry', function (entry) {
var fileName = entry.path;
var type = entry.type; // 'Directory' or 'File'
var size = entry.size;
console.log(fileName)
if (fileName === "ffmpeg-latest-win32-static/bin/ffmpeg.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffprobe.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffplay.exe") {
entry.pipe(fs.createWriteStream(global.dir+'/lib/'+fileName.split('/')[2]));
console.log('TEST')
z++;
if(z == 3){
libs.checkNext('youtube-dl');
}
} else {
entry.autodrain();
} }
}); break;
}); default:
break; }
case "linux":
libs.download(url,"ffmpeg",function(data,file){
const ls = spawn('tar', ['xvf','./src/tmp/ffmpeg.x-xz','-C','./src/tmp']);
ls.stdout.on('data', (data) => { for (var lib in libsx) {
console.log(`stdout: ${data}`); if (fs.existsSync(global.dir + "/lib/" + libsx[lib])) {
});
ls.stderr.on('data', (data) => { } else {
console.log(`stderr: ${data}`); libsx[lib] = null;
}); }
}
libs.libs = libsx;
if (libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null) {
var z = 0;
var url = libs.ff(process.platform);
if (url === '') {
libs.checkNext('youtube-dl');
} else {
switch (process.platform) {
case "win32":
libs.download(url, "ffmpeg", function(data, file) {
fs.createReadStream(file)
.pipe(unzip.Parse())
.on('entry', function(entry) {
var fileName = entry.path;
var type = entry.type; // 'Directory' or 'File'
var size = entry.size;
console.log(fileName)
if (fileName === "ffmpeg-latest-win32-static/bin/ffmpeg.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffprobe.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffplay.exe") {
entry.pipe(fs.createWriteStream(global.dir + '/lib/' + fileName.split('/')[2]));
console.log('TEST')
z++;
if (z == 3) {
libs.checkNext('youtube-dl');
}
} else {
entry.autodrain();
}
});
});
break;
case "linux":
libs.download(url, "ffmpeg", function(data, file) {
const ls = spawn('tar', ['xvf', './src/tmp/ffmpeg.x-xz', '-C', './src/tmp']);
ls.on('close', (code) => { ls.stdout.on('data', (data) => {
var folder = ""; console.log(`stdout: ${data}`);
console.log(`child process exited with code ${code}`); });
const ls = spawn('rm', ['./src/tmp/ffmpeg.x-xz']).on('close',()=>{
const ls = spawn('ls', ['./src/tmp/']).stdout.on(data,(data)=>{ ls.stderr.on('data', (data) => {
console.log(data) console.log(`stderr: ${data}`);
if(data.match('ffmpeg-') && data.match('-static')){ });
folder = data;
} ls.on('close', (code) => {
}).on('close',()=>{ var folder = "";
const ls = spawn('cp', ['./src/tmp/'+folder+'/ffmpeg','./src/lib/ffmpeg']).on('close',()=>{ console.log(`child process exited with code ${code}`);
const ls = spawn('cp', ['./src/tmp/'+folder+'/ffprobe','./src/lib/ffprobe']).on('close',()=>{ const ls = spawn('rm', ['./src/tmp/ffmpeg.x-xz']).on('close', () => {
libs.checkNext('youtube-dl'); const ls = spawn('ls', ['./src/tmp/']).stdout.on(data, (data) => {
}); console.log(data)
}); if (data.match('ffmpeg-') && data.match('-static')) {
}); folder = data;
}); }
}); }).on('close', () => {
const ls = spawn('cp', ['./src/tmp/' + folder + '/ffmpeg', './src/lib/ffmpeg']).on('close', () => {
const ls = spawn('cp', ['./src/tmp/' + folder + '/ffprobe', './src/lib/ffprobe']).on('close', () => {
libs.checkNext('youtube-dl');
});
});
});
});
});
}) })
break; break;
default: default:
} }
} }
}else{ } else {
libs.checkNext('youtube-dl'); libs.checkNext('youtube-dl');
} }
console.dir(libsx); console.dir(libsx);
}) })
libs.checkNext = (nxt)=>{ libs.checkNext = (nxt) => {
if( libs.libs['youtube-dl'] === null ){ if (libs.libs['youtube-dl'] === null) {
libs.yt_dl(process.platform,function(){ libs.yt_dl(process.platform, function() {
libs.startFull(); libs.startFull();
}); });
}else{ } else {
libs.startFull(); libs.startFull();
} }
} }
libs.startFull = ()=>{ libs.startFull = () => {
libs.listen.sender.send('fin-loading',{}); libs.listen.sender.send('fin-loading', {});
} }
libs.ff = (os)=>{ libs.ff = (os) => {
var url = ""; var url = "";
switch (os) { switch (os) {
case "win32": case "win32":
@ -134,20 +136,20 @@ libs.ff = (os)=>{
} }
return url; return url;
} }
libs.yt_dl = (os,cb)=>{ libs.yt_dl = (os, cb) => {
var url = ""; var url = "";
switch (os) { switch (os) {
case "win32": case "win32":
url = 'https://yt-dl.org/downloads/2017.08.13/youtube-dl.exe'; url = 'https://yt-dl.org/downloads/2017.08.13/youtube-dl.exe';
libs.download(url,"youtube-dl",function(data,file){ libs.download(url, "youtube-dl", function(data, file) {
fs.renameSync(file,global.dir+'/lib/youtube-dl.exe'); fs.renameSync(file, global.dir + '/lib/youtube-dl.exe');
cb(); cb();
}) })
break; break;
case "linux": case "linux":
url = 'https://yt-dl.org/downloads/latest/youtube-dl' url = 'https://yt-dl.org/downloads/latest/youtube-dl'
libs.download(url,"youtube-dl",function(data,file){ libs.download(url, "youtube-dl", function(data, file) {
fs.renameSync(file,global.dir+'/lib/youtube-dl'); fs.renameSync(file, global.dir + '/lib/youtube-dl');
cb(); cb();
}) })
default: default:
@ -156,28 +158,30 @@ libs.yt_dl = (os,cb)=>{
} }
libs.download = (url,data,cb)=>{ libs.download = (url, data, cb) => {
var r = request(url); var r = request(url);
var actual = 1; var actual = 1;
var full = 100; var full = 100;
var perc = 0; var perc = 0;
r.on('data', function (chunk) { r.on('data', function(chunk) {
actual += chunk.length; actual += chunk.length;
perc = actual / full * 100; perc = actual / full * 100;
console.log(perc); console.log(perc);
libs.listen.sender.send('progress',{percent :Math.floor(perc)}); libs.listen.sender.send('progress', {
percent: Math.floor(perc)
});
}); });
r.on('response', function (res) { r.on('response', function(res) {
res.pipe(fs.createWriteStream(global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1])); res.pipe(fs.createWriteStream(global.dir + '/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]));
full = res.headers[ 'content-length' ] ; full = res.headers['content-length'];
res.on('end', function () { res.on('end', function() {
cb(data,global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]); cb(data, global.dir + '/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]);
}) })
}); });
} }
function win_ffmpeg(){ function win_ffmpeg() {
} }

View File

@ -1,4 +1,6 @@
const { exec } = require('child_process'); const {
exec
} = require('child_process');
var install = {}; var install = {};
@ -6,48 +8,50 @@ var install = {};
install.init = (cb)=>{ install.init = (cb) => {
var url = [ var url = [
['ffmpeg','https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz'], ['ffmpeg', 'https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz'],
['youtube-dl' ,'https://yt-dl.org/downloads/latest/youtube-dl'] ['youtube-dl', 'https://yt-dl.org/downloads/latest/youtube-dl']
] ]
var download = (i)=>{ var download = (i) => {
install.download(url[i],function(path){ install.download(url[i], function(path) {
switch (i) { switch (i) {
case 0: case 0:
shell. shell.
break; break;
default: default:
} }
if(i<url.length-1){ if (i < url.length - 1) {
download(i++); download(i++);
}else{ } else {
cb(); cb();
} }
}) })
}; };
download(0) download(0)
} }
install.download = (url,cb) =>{ install.download = (url, cb) => {
var r = request(url); var r = request(url);
var actual = 1; var actual = 1;
var full = 100; var full = 100;
var perc = 0; var perc = 0;
r.on('data', function (chunk) { r.on('data', function(chunk) {
actual += chunk.length; actual += chunk.length;
perc = actual / full * 100; perc = actual / full * 100;
console.log(perc); console.log(perc);
libs.listen.sender.send('progress',{percent :Math.floor(perc)}); libs.listen.sender.send('progress', {
}); percent: Math.floor(perc)
r.on('response', function (res) { });
var path = global.dir+'/tmp/'+url.split('/')[url.split('/').length-1]; });
res.pipe(fs.createWriteStream( path )); r.on('response', function(res) {
full = res.headers[ 'content-length' ] ; var path = global.dir + '/tmp/' + url.split('/')[url.split('/').length - 1];
res.on('end', function () { res.pipe(fs.createWriteStream(path));
cb(path); full = res.headers['content-length'];
}) res.on('end', function() {
}); cb(path);
})
});
} }

View File

@ -15,36 +15,40 @@ var s = null;
var pot_open_ev = null; var pot_open_ev = null;
ipcMain ipcMain
.on('close_pot',(event,arg)=>{ .on('close_pot', (event, arg) => {
console.log('CLOSE') console.log('CLOSE')
pot.close(event); pot.close(event);
}) })
.on('pot_run',(event,arg)=>{ .on('pot_run', (event, arg) => {
pot_open_ev.sender.send('pot_play',arg); pot_open_ev.sender.send('pot_play', arg);
}) })
.on('pot_real_open',(event,arg)=>{ .on('pot_real_open', (event, arg) => {
console.log('POT EVENT SET') console.log('POT EVENT SET')
pot_open_ev = event; pot_open_ev = event;
}) })
.on('open-pot',(event,arg)=>{ .on('open-pot', (event, arg) => {
pot.open(event); pot.open(event);
}) })
pot.isOpen = false; pot.isOpen = false;
pot.open = (e) => { pot.open = (e) => {
s = e; s = e;
if (win !== null) { if (win !== null) {
e.sender.send('play-in-Window',{do :false}); e.sender.send('play-in-Window', {
do: false
});
win.close(); win.close();
} }
var x = new playerOnTop(e); var x = new playerOnTop(e);
} }
pot.close = ()=>{ pot.close = () => {
console.log('CLOSE') console.log('CLOSE')
s.sender.send('play-in-Window',{do :false}); s.sender.send('play-in-Window', {
do: false
});
win.close(); win.close();
} }
@ -60,21 +64,25 @@ class playerOnTop {
alwaysOnTop: true, alwaysOnTop: true,
icon: global.dir + '/app.ico' icon: global.dir + '/app.ico'
}) })
e.sender.send('play-in-Window',{do :true}); e.sender.send('play-in-Window', {
do: true
});
win = this.win; win = this.win;
win.loadURL(`file://${global.dir}/app/view/pot.html`) win.loadURL(`file://${global.dir}/app/view/pot.html`)
win.once('ready-to-show', () => { win.once('ready-to-show', () => {
win.show(); win.show();
}) })
win.on('resize', function () { win.on('resize', function() {
setTimeout(function () { setTimeout(function() {
var size = win.getSize(); var size = win.getSize();
win.setSize(size[0], parseInt(size[0] * 9 / 16)); win.setSize(size[0], parseInt(size[0] * 9 / 16));
}, 0); }, 0);
}); });
win.on('closed', () => { win.on('closed', () => {
pot.isOpen = false; pot.isOpen = false;
e.sender.send('play-in-Window',{do :false}); e.sender.send('play-in-Window', {
do: false
});
win = null; win = null;
}); });
} }

View File

@ -1,28 +1,41 @@
const {app, Menu, Tray} = require('electron') const {
app,
Menu,
Tray
} = require('electron')
const main_window = require('./windows.js/main.js') const main_window = require('./windows.js/main.js')
const path = require('path') const path = require('path')
module.exports = ()=>{ module.exports = () => {
switch(process.platform){ switch (process.platform) {
case 'win32': case 'win32':
break; break;
case 'linux': case 'linux':
break; break;
} }
let tray = new Tray(path.join(global.dir+'/app.png')) let tray = new Tray(path.join(global.dir + '/app.png'))
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([{
{label: 'Open', click(){ main_window.open() }}, label: 'Open',
click() {
main_window.open()
}
},
/*{label: 'About',click() { console.log('item 1 clicked') }}, /*{label: 'About',click() { console.log('item 1 clicked') }},
{label: 'Item1', type: 'radio'}, {label: 'Item1', type: 'radio'},
{type: 'separator'}, {type: 'separator'},
{label: 'Item2', type: 'radio'}, {label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},*/ {label: 'Item3', type: 'radio', checked: true},*/
{label: 'Beenden', click() { main_window.close(); }}, {
label: 'Beenden',
click() {
main_window.close();
}
},
]) ])
tray.setToolTip('Cyb3r Downloader.') tray.setToolTip('Cyb3r Downloader.')
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu)

View File

@ -1,14 +1,14 @@
const watchr = require('watchr'); const watchr = require('watchr');
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const ipcMain = require('electron').ipcMain; const ipcMain = require('electron').ipcMain;
var watch_event = null; var watch_event = null;
ipcMain ipcMain
.on('watchr_event', (event, arg)=>{ .on('watchr_event', (event, arg) => {
watch_event = event watch_event = event
}) })
class folderWatchr { class folderWatchr {
constructor(folder) { constructor(folder) {
@ -20,9 +20,12 @@ class folderWatchr {
files.push(folder + '/' + file); files.push(folder + '/' + file);
}); });
for(var i = 0;i<files.length;i++){ for (var i = 0; i < files.length; i++) {
files[i]=files[i].replace(/\\/g, "/"); files[i] = files[i].replace(/\\/g, "/");
watch_event.sender.send('watchr_file',{type:"add",file:files[i]}); watch_event.sender.send('watchr_file', {
type: "add",
file: files[i]
});
} }
function listener(changeType, fullPath, currentStat, previousStat) { function listener(changeType, fullPath, currentStat, previousStat) {
@ -36,10 +39,16 @@ class folderWatchr {
console.log('the file', fullPath, 'was created', currentStat) console.log('the file', fullPath, 'was created', currentStat)
files.push(fullPath); files.push(fullPath);
watch_event.sender.send('watchr_file',{type:"add",file:fullPath}); watch_event.sender.send('watchr_file', {
type: "add",
file: fullPath
});
break; break;
case 'delete': case 'delete':
watch_event.sender.send('watchr_file',{type:"remove",file:fullPath}); watch_event.sender.send('watchr_file', {
type: "remove",
file: fullPath
});
files.splice(files.indexOf(fullPath), 1); files.splice(files.indexOf(fullPath), 1);
break; break;
} }
@ -51,9 +60,9 @@ class folderWatchr {
} }
// Watch the path with the change listener and completion callback // Watch the path with the change listener and completion callback
this.stalker = watchr.open(this.folder , listener, next); this.stalker = watchr.open(this.folder, listener, next);
} }
destroy(){ destroy() {
this.stalker.close() this.stalker.close()
} }
} }

View File

@ -3,9 +3,9 @@ var cors = require('cors')
app.use(cors()) app.use(cors())
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
app.use( bodyParser.json() ); // to support JSON-encoded bodies app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true extended: true
})); }));

View File

@ -1,14 +1,12 @@
const { const {
BrowserWindow, BrowserWindow,
session session
} = require('electron'); } = require('electron');
const crunch = require('./../crunchyroll') const crunch = require('./../crunchyroll')
class browser { class browser {
constructor(url){ constructor(url) {
console.log("TEST") console.log("TEST")
this.window = new BrowserWindow({ this.window = new BrowserWindow({
width: 500, width: 500,
@ -17,12 +15,14 @@ class browser {
frame: true, frame: true,
icon: global.dir + '/app.ico' icon: global.dir + '/app.ico'
}) })
setInterval(function(){ setInterval(function() {
session.defaultSession.cookies.get({url:'http://crunchyroll.com'}, (error, cookies) => { session.defaultSession.cookies.get({
//console.log(error, cookies) url: 'http://crunchyroll.com'
crunch.session_save(cookies); }, (error, cookies) => {
//console.log(error, cookies)
crunch.session_save(cookies);
}) })
},3000) }, 3000)
var window = this.window var window = this.window
window.loadURL(url) window.loadURL(url)
window.once('ready-to-show', () => { window.once('ready-to-show', () => {
@ -30,7 +30,7 @@ class browser {
}) })
this.window.on('closed', () => { this.window.on('closed', () => {
window = null; window = null;
}); });
} }
} }

View File

@ -1,5 +1,10 @@
const { spawn } = require('child_process'); const {
const {Notification,ipcMain}= require('electron'); spawn
} = require('child_process');
const {
Notification,
ipcMain
} = require('electron');
const dl_routine = require('./youtube-dl.routine') const dl_routine = require('./youtube-dl.routine')
const nodeID3 = require('node-id3'); const nodeID3 = require('node-id3');
@ -15,151 +20,169 @@ var format = "mp3";
var fol = null; var fol = null;
var pot_open_ev = null; var pot_open_ev = null;
var request = require('request').defaults({ encoding: null }); var request = require('request').defaults({
encoding: null
ipcMain
.on('start-download', (event, arg)=>{
path = orig_path
var download = new yt_dl(arg.url,arg.id);
download.addListen(event)
download.download();
})
.on('set-format',(event,arg)=>{
format = arg.format;
})
.on('start-download-pl', (event, arg)=>{
var mkdirp = require('mkdirp');
if(orig_path === ""){
path = '.'
}else{
path = orig_path
}
mkdirp(path+'/'+arg.folder, function(err) {
path = path+'/'+arg.folder;
// path exists unless there was an error
var download = new yt_dl(arg.url,arg.id);
download.addListen(event)
download.download();
});
})
.on('setPath', function(event, arg) {
path = arg.path;
orig_path = arg.path;
if(fol !== null){
fol.destroy()
}
fol = new folderWatchr(path);
console.log('SET Path: '+path)
}); });
var yt_dl = class{ ipcMain
constructor(url,id){ .on('start-download', (event, arg) => {
this.url = url ; path = orig_path
var download = new yt_dl(arg.url, arg.id, arg.title);
download.addListen(event)
download.download();
})
.on('set-format', (event, arg) => {
format = arg.format;
})
.on('start-download-pl', (event, arg) => {
var mkdirp = require('mkdirp');
if (orig_path === "") {
path = '.'
} else {
path = orig_path
}
mkdirp(path + '/' + arg.folder, function(err) {
path = path + '/' + arg.folder;
// path exists unless there was an error
var download = new yt_dl(arg.url, arg.id);
download.addListen(event)
download.download();
});
})
.on('setPath', function(event, arg) {
path = arg.path;
orig_path = arg.path;
if (fol !== null) {
fol.destroy()
}
fol = new folderWatchr(path);
console.log('SET Path: ' + path)
});
var yt_dl = class {
constructor(url, id, title) {
this.url = url;
this.percent = 0; this.percent = 0;
this.lwrite = null; this.lwrite = null;
this.id = id; this.id = id;
this.title = title
} }
addListen(e){ addListen(e) {
this.lwrite = e this.lwrite = e
} }
status(stat){ status(stat) {
this.lwrite('download-progress', stat); this.lwrite('download-progress', stat);
} }
download(){ download() {
var log = []; var log = [];
var me = this; var me = this;
var ls; var ls;
var m = dl_routine(path,this.url,format); var m = dl_routine(path, this.url, format, this.title);
ls = spawn(m[0],m[1]); ls = spawn(m[0], m[1]);
if(path == ''){ if (path == '') {
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url]); //ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url]);
}else{ } else {
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url,'-o',path+'/%(title)s.%(ext)s']); //ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url,'-o',path+'/%(title)s.%(ext)s']);
} }
ls.stdout.on('data', (data) => { ls.stdout.on('data', (data) => {
data = data.toString('utf8'); data = data.toString('utf8');
log.push(data); log.push(data);
//console.log(data); //console.log(data);
try{ try {
var z = data.replace(/(\r\n|\n|\r)/gm,"").split(' '); var z = data.replace(/(\r\n|\n|\r)/gm, "").split(' ');
console.log(z) console.log(z)
switch (z[0]) { switch (z[0]) {
case '[download]': case '[download]':
var percent = data.split(']')[1].split('of')[0]; var percent = data.split(']')[1].split('of')[0];
//console.log(z) //console.log(z)
me.percent = percent.trim(); me.percent = percent.trim();
me.lwrite.sender.send('download-progress',{percent :me.percent,id:me.id}); me.lwrite.sender.send('download-progress', {
break; percent: me.percent,
default: id: me.id
} });
var m = z.length; break;
for(var i = 0;i<m;i++){ default:
if(z[i] === '[ffmpeg]'){ }
if(z[i+1] === 'Merging'){ var m = z.length;
var file = ""; for (var i = 0; i < m; i++) {
for(var x = i+4;x<m;x++){ if (z[i] === '[ffmpeg]') {
console.log(z[x]) if (z[i + 1] === 'Merging') {
if(z[x] === 'has' && z[x+1] === "already" && z[x+2] === "been" && z[x+3] === 'downloaded'){ var file = "";
break; for (var x = i + 4; x < m; x++) {
} console.log(z[x])
file = z[x]; if (z[x] === 'has' && z[x + 1] === "already" && z[x + 2] === "been" && z[x + 3] === 'downloaded') {
} break;
me.lwrite.sender.send('file',{id:me.id,file:file}); }
break; file = z[x];
} }
} me.lwrite.sender.send('file', {
} id: me.id,
}catch(e){ file: file
console.log(e); });
}finally{ break;
}
}
}
} catch (e) {
console.log(e);
} finally {
} }
}); });
ls.stderr.on('data', (data) => { ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`); console.log(`stderr: ${data}`);
}); });
ls.on('close', (code) => { ls.on('close', (code) => {
console.log(`child process exited with code ${code}`); console.log(`child process exited with code ${code}`);
me.lwrite.sender.send('file',{id:me.id,file:log[log.length-2].split('[ffmpeg] Destination: ')[1]}); me.lwrite.sender.send('file', {
me.lwrite.sender.send('process-fin',{percent :me.percent,id:me.id}); id: me.id,
file: log[log.length - 2].split('[ffmpeg] Destination: ')[1]
});
me.lwrite.sender.send('process-fin', {
percent: me.percent,
id: me.id
});
var title = this.title;
if(this.url.match('youtube')){ if (this.url.match('youtube')) {
var url = this.url; var url = this.url;
var video_id = this.url.split('v=')[1]; var video_id = this.url.split('v=')[1];
var ampersandPosition = video_id.indexOf('&'); var ampersandPosition = video_id.indexOf('&');
if (ampersandPosition != -1) { if (ampersandPosition != -1) {
video_id = video_id.substring(0, ampersandPosition); video_id = video_id.substring(0, ampersandPosition);
}
/*
var x = new Notification({
title:"Cyb3r Downloader",
body :"finished download for "+url,
//icon : body
})
x.show()
//request.get('https://i.ytimg.com/vi/'+video_id+'/hqdefault.jpg', function (err, res, body) {
//log[log.length-2].split('[ffmpeg] Destination: ')[1]
/*var tags = {
image: body
} }
var success = nodeID3.write(tags, log[log.length-2].split('[ffmpeg] Destination: ')[1]); var fornoti = title;
console.log(success);*/ if (title === "") {
//}); fornoti = url;
} }
var x = new Notification({
title: "Cyb3r Downloader",
body: "finished download for " + title,
//icon : body
})
x.show()
request.get('https://i.ytimg.com/vi/' + video_id + '/hqdefault.jpg', function(err, res, body) {
//log[log.length-2].split('[ffmpeg] Destination: ')[1]
var tags = {
image: body
}
var success = nodeID3.write(tags, path + '/' + title + '.' + format);
console.log(success);
});
}
}); });
} }
} }

View File

@ -1,30 +1,26 @@
module.exports = (path, url, format, title = "%(title)s") => {
var command = global.dir + '/lib/youtube-dl';
var param = [];
module.exports = (path,url,format)=>{
var command = global.dir+'/lib/youtube-dl';
var param = [];
console.log(url); console.log(url);
if(url.match('youtube')){ if (url.match('youtube')) {
console.log('youtube') console.log('youtube')
switch (format) { switch (format) {
case "mp3": case "mp3":
param = ['-x','--audio-format','mp3','-i',url,'-o',path+'/%(title)s.%(ext)s']; param = ['-x', '--audio-format', 'mp3', '-i', url, '-o', path + '/'+title+'.%(ext)s'];
break; break;
case "mp4": case "mp4":
param = ['-w','-f','bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',url,'-o',path+'/%(title)s.%(ext)s']; param = ['-w', '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4', url, '-o', path + '/'+title+'.%(ext)s'];
break; break;
default: default:
} }
} } else if (url.match('crunchyroll')) {
else if(url.match('crunchyroll')){
console.log('crunchyroll') console.log('crunchyroll')
param = ['--cookie', global.dir+'/tmp/c', '--all-subs', '--sub-format', 'srt', '--write-sub', '--embed-subs',url,'-o',path+'/%(title)s.%(ext)s']; param = ['--cookie', global.dir + '/tmp/c', '--all-subs', '--sub-format', 'srt', '--write-sub', '--embed-subs', url, '-o', path + '/%(title)s.%(ext)s'];
} }
return [command,param]; return [command, param];

View File

@ -20,29 +20,6 @@ let tray_win = null;
if (!fs.existsSync(global.dir+'/tmp/inst')) { if (!fs.existsSync(global.dir+'/tmp/inst')) {
fs.writeFileSync(global.dir+'/tmp/inst',"out"); fs.writeFileSync(global.dir+'/tmp/inst',"out");
app.quit(); app.quit();
/*var win;
const createWindow = () =>{
win = new BrowserWindow({
width: 320,
height: 500,
show: false,
frame: false,
icon: __dirname + '/app.ico'
})
win.once('ready-to-show', () => {
})
win.on('closed', () => {
win = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
*/
}else{ }else{
var win ; var win ;
app.getPath('documents') app.getPath('documents')
@ -56,8 +33,6 @@ if (!fs.existsSync(global.dir+'/tmp/inst')) {
}) })
ipcMain ipcMain
.on('start-full', (event, arg)=>{ .on('start-full', (event, arg)=>{
//main_window.createWindow(); //main_window.createWindow();
//main_window.open(); //main_window.open();
tray_win = tray(); tray_win = tray();
@ -67,27 +42,18 @@ if (!fs.existsSync(global.dir+'/tmp/inst')) {
win.loadURL(`file://${__dirname}/app/view/init.html`) win.loadURL(`file://${__dirname}/app/view/init.html`)
win.once('ready-to-show', () => { win.once('ready-to-show', () => {
win.show() win.show()
//var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4")
//x.download();
}) })
win.on('closed', () => { win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null; win = null;
}); });
} }
app.on('ready', createWindow); app.on('ready', createWindow);
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
app.quit(); app.quit();
} }
}); });
app.on('activate', () => { app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) { if (mainWindow === null) {
createWindow(); createWindow();
} }