starting with linux
This commit is contained in:
Luca Jäntsch 2017-08-14 17:20:34 +02:00
parent afc4000458
commit 2f694bc661
5 changed files with 106 additions and 25 deletions

4
src/app/style/style.css Normal file
View File

@ -0,0 +1,4 @@
body {
margin: 0;
background: #333;
}

View File

@ -16,6 +16,7 @@
<link rel="stylesheet" href="./../libs/bootstrap/css/bootstrap.css" /> <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/css/bootstrap-theme.css" />
<link rel="stylesheet" href="./../style/progress.css" /> <link rel="stylesheet" href="./../style/progress.css" />
<link rel="stylesheet" href="./../style/style.css" />
</head> </head>
<body> <body>

View File

@ -37,7 +37,11 @@ ipcMain
libs.libs = libsx; libs.libs = libsx;
if(libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null ){ if(libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null ){
var z = 0; var z = 0;
libs.download(libs.ff(process.platform),"ffmpeg",function(data,file){ var url = libs.ff(process.platform);
if(url === ''){
libs.checkNext('youtube-dl');
}else{
libs.download(url,"ffmpeg",function(data,file){
fs.createReadStream(file) fs.createReadStream(file)
.pipe(unzip.Parse()) .pipe(unzip.Parse())
.on('entry', function (entry) { .on('entry', function (entry) {
@ -57,6 +61,7 @@ ipcMain
} }
}); });
}); });
}
}else{ }else{
libs.checkNext('youtube-dl'); libs.checkNext('youtube-dl');
} }
@ -80,6 +85,9 @@ libs.ff = (os)=>{
case "win32": case "win32":
url = 'http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip'; url = 'http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip';
break; break;
case "linux":
url = ''
default: default:
} }
@ -89,15 +97,19 @@ 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';
break;
default:
}
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;
case "linux":
url = ''
cb();
default:
}
} }
libs.download = (url,data,cb)=>{ libs.download = (url,data,cb)=>{

View File

@ -0,0 +1,53 @@
const { exec } = require('child_process');
var install = {};
install.init = (cb)=>{
var url = [
['ffmpeg','https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz'],
['youtube-dl' ,'https://yt-dl.org/downloads/latest/youtube-dl']
]
var download = (i)=>{
install.download(url[i],function(path){
switch (i) {
case 0:
shell.
break;
default:
}
if(i<url.length-1){
download(i++);
}else{
cb();
}
})
};
download(0)
}
install.download = (url,cb) =>{
var r = request(url);
var actual = 1;
var full = 100;
var perc = 0;
r.on('data', function (chunk) {
actual += chunk.length;
perc = actual / full * 100;
console.log(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 ));
full = res.headers[ 'content-length' ] ;
res.on('end', function () {
cb(path);
})
});
}

View File

@ -1,6 +1,17 @@
var app = require('./index'); var app = require('./index');
var handleStartupEvent = function() { var handleStartupEvent = function() {
console.log(process.platform);
switch (process.platform) {
case 'win32':
break;
case 'linux':
break;
default:
}
if (process.platform !== 'win32') { if (process.platform !== 'win32') {
return false; return false;
} }