1.4.0 Alpha

This commit is contained in:
2017-08-28 03:50:31 +02:00
parent acab4b1908
commit d7958e1594
17 changed files with 637 additions and 102 deletions

View File

@@ -22,13 +22,13 @@ crunch.session_save = (session)=>{
}
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);
fs.writeFile(global.dir+"/tmp/c", net, function(err) {
//console.log(net);
/*fs.writeFile(global.dir+"/tmp/c", net, function(err) {
if(err) {
return console.log(err);
}
console.log("T!");
});
//console.log("T!");
});*/
}
module.exports = crunch;

View File

@@ -0,0 +1,73 @@
const {
app,
BrowserWindow,
Menu,
dialog,
ipcMain
} = require('electron');
//alwaysOnTop
var win = null;
var pot = {};
var s = null;
ipcMain
.on('close_pot',(event,arg)=>{
console.log('CLOSE')
pot.close(event);
})
pot.isOpen = false;
pot.open = (e) => {
s = e;
if (win !== null) {
e.sender.send('play-in-Window',{do :false});
win.close();
}
var x = new playerOnTop(e);
console.log('XX');
}
pot.close = ()=>{
console.log('CLOSE')
s.sender.send('play-in-Window',{do :false});
win.close();
}
class playerOnTop {
constructor(e) {
pot.isOpen = true;
this.win = new BrowserWindow({
width: 320,
height: 500,
show: false,
frame: false,
alwaysOnTop: true,
icon: global.dir + '/app.ico'
})
e.sender.send('play-in-Window',{do :true});
win = this.win;
win.loadURL(`file://${global.dir}/app/view/pot.html`)
win.once('ready-to-show', () => {
win.show();
console.log('XX');
})
win.on('resize', function () {
setTimeout(function () {
var size = win.getSize();
win.setSize(size[0], parseInt(size[0] * 9 / 16));
}, 0);
});
win.on('closed', () => {
pot.isOpen = false;
e.sender.send('play-in-Window',{do :false});
win = null;
console.log('XX');
});
}
}
module.exports = pot;

61
src/controller/watchr.js Normal file
View File

@@ -0,0 +1,61 @@
const watchr = require('watchr');
const fs = require('fs')
const path = require('path')
const ipcMain = require('electron').ipcMain;
var watch_event = null;
ipcMain
.on('watchr_event', (event, arg)=>{
watch_event = event
})
class folderWatchr {
constructor(folder) {
this.folder = folder;
this.files = [];
var files = this.files;
fs.readdirSync(this.folder).forEach(file => {
files.push(folder + '/' + file);
});
for(var i = 0;i<files.length;i++){
files[i]=files[i].replace(/\\/g, "/");
watch_event.sender.send('watchr_file',{type:"add",file:files[i]});
}
function listener(changeType, fullPath, currentStat, previousStat) {
console.log(changeType);
fullPath = fullPath.replace(/\\/g, "/");
switch (changeType) {
case 'update':
break;
case 'create':
console.log('the file', fullPath, 'was created', currentStat)
files.push(fullPath);
watch_event.sender.send('watchr_file',{type:"add",file:fullPath});
break;
case 'delete':
watch_event.sender.send('watchr_file',{type:"remove",file:fullPath});
files.splice(files.indexOf(fullPath), 1);
break;
}
}
function next(err) {
if (err) return console.log('watch failed on', path, 'with error', err);
console.log('watch successful on', path);
}
// Watch the path with the change listener and completion callback
this.stalker = watchr.open(this.folder , listener, next);
}
destroy(){
this.stalker.close()
}
}
module.exports = folderWatchr;

View File

@@ -1,13 +1,31 @@
const { spawn } = require('child_process');
const ipcMain = require('electron').ipcMain;
const dl_routine = require('./youtube-dl.routine')
const pot = require('./player_onTop')
const folderWatchr = require('./watchr')
console.log(global.dir);
var orig_path = "";
var path = "";
var format = "mp3";
var fol = null;
var pot_open_ev = null;
ipcMain
.on('pot_run',(event,arg)=>{
pot_open_ev.sender.send('pot_play',arg);
})
.on('pot_real_open',(event,arg)=>{
console.log('POT EVENT SET')
pot_open_ev = event;
})
ipcMain
.on('open-pot',(event,arg)=>{
pot.open(event);
})
.on('start-download', (event, arg)=>{
path = orig_path
var download = new yt_dl(arg.url,arg.id);
@@ -35,6 +53,10 @@ ipcMain
ipcMain.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)
});
@@ -79,7 +101,23 @@ var yt_dl = class{
me.lwrite.sender.send('download-progress',{percent :me.percent,id:me.id});
break;
default:
}
var m = z.length;
for(var i = 0;i<m;i++){
if(z[i] === '[ffmpeg]'){
if(z[i+1] === 'Merging'){
var file = "";
for(var x = i+4;x<m;x++){
console.log(z[x])
if(z[x] === 'has' && z[x+1] === "already" && z[x+2] === "been" && z[x+3] === 'downloaded'){
break;
}
file = z[x];
}
me.lwrite.sender.send('file',{id:me.id,file:file});
break;
}
}
}
}catch(e){
console.log(e);

View File

@@ -12,7 +12,7 @@ module.exports = (path,url,format)=>{
param = ['-x','--audio-format','mp3','-i',url,'-o',path+'/%(title)s.%(ext)s'];
break;
case "mp4":
param = ['-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)s.%(ext)s'];
break;
default: