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-theme.css" />
<link rel="stylesheet" href="./../style/progress.css" />
<link rel="stylesheet" href="./../style/style.css" />
</head>
<body>

View File

@ -37,26 +37,31 @@ ipcMain
libs.libs = libsx;
if(libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null ){
var z = 0;
libs.download(libs.ff(process.platform),"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');
var url = libs.ff(process.platform);
if(url === ''){
libs.checkNext('youtube-dl');
}else{
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();
}
} else {
entry.autodrain();
}
});
});
});
});
}
}else{
libs.checkNext('youtube-dl');
}
@ -80,6 +85,9 @@ libs.ff = (os)=>{
case "win32":
url = 'http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip';
break;
case "linux":
url = ''
default:
}
@ -89,15 +97,19 @@ libs.yt_dl = (os,cb)=>{
var url = "";
switch (os) {
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){
fs.renameSync(file,global.dir+'/lib/youtube-dl.exe');
cb();
})
break;
case "linux":
url = ''
cb();
default:
}
libs.download(url,"youtube-dl",function(data,file){
fs.renameSync(file,global.dir+'/lib/youtube-dl.exe');
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 handleStartupEvent = function() {
console.log(process.platform);
switch (process.platform) {
case 'win32':
break;
case 'linux':
break;
default:
}
if (process.platform !== 'win32') {
return false;
}