This commit is contained in:
Luca Jäntsch 2017-09-29 14:20:55 +02:00 committed by Theenoro
parent 43fa503dcf
commit 3d5d5320bd
7 changed files with 16441 additions and 148 deletions

16192
package-lock.json generated

File diff suppressed because it is too large Load Diff

BIN
src/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -10,7 +10,7 @@
</script> </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/bootstrap/js/bootstrap.js"></script>--> <script src="./../libs/bootstrap/js/bootstrap.js"></script>-->
<script src="./../libs/jquery/jquery-3.2.1.slim.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>
@ -33,7 +33,9 @@
<div class="list-group" role="tablist" id=""> <div class="list-group" role="tablist" id="">
<li role="presentation" class="list-group-item list-group-item-action"><a href="#download" aria-controls="download" role="tab" data-toggle="tab">Download</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#download" aria-controls="download" role="tab" data-toggle="tab">Download</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#player" aria-controls="player" role="tab" data-toggle="tab">Player</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#player" aria-controls="player" role="tab" data-toggle="tab">Player</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#wt" aria-controls="wt" role="tab" data-toggle="tab">Watch Together</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#info" aria-controls="info" role="tab" data-toggle="tab">Info</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#info" aria-controls="info" role="tab" data-toggle="tab">Info</a></li>
</div> </div>
</div> </div>
</div> </div>
@ -48,13 +50,14 @@
</nav> </nav>
<div class="row"> <div class="row">
<div class="col-md-2" style="display:none"> <div class="col-md-2" style="display:none">
<div class="list-group" role="tablist" > <div class="list-group" role="tablist">
<li role="presentation" class="list-group-item list-group-item-action"><a href="#download" aria-controls="download" role="tab" data-toggle="tab">Download</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#download" aria-controls="download" role="tab" data-toggle="tab">Download</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#player" aria-controls="player" role="tab" data-toggle="tab">Player</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#player" aria-controls="player" role="tab" data-toggle="tab">Player</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#wt" aria-controls="wt" role="tab" data-toggle="tab">Watch Together</a></li>
<li role="presentation" class="list-group-item list-group-item-action"><a href="#info" aria-controls="info" role="tab" data-toggle="tab">Info</a></li> <li role="presentation" class="list-group-item list-group-item-action"><a href="#info" aria-controls="info" role="tab" data-toggle="tab">Info</a></li>
</div> </div>
</div> </div>
<div class="col-md-12" > <div class="col-md-12">
<div style="max-width:380px;margin:auto;margin-bottom:25px;"> <div style="max-width:380px;margin:auto;margin-bottom:25px;">
<div style=" margin: 0; <div style=" margin: 0;
@ -127,6 +130,48 @@
</div> </div>
</div> </div>
</div> </div>
<div role="tabpanel" class="tab-pane fade" id="wt">
<div class="row">
<div class="col-md-12">
<div class="input-group">
<input type="text" class="form-control" id="webview-url" placeholder="www..." aria-label="Product name">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button" id="webviewload">-></button>
<button class="btn btn-secondary" type="button" id="webviewdownload">Cyb3r Download</button>
</span>
</div>
<webview id="foo" src="https://youtube.com/" style="display:inline-flex; width:100%; height:calc(100vh - 144px)"></webview>
</div>
<script>
$(function(){
const webview = document.querySelector('webview')
const indicator = document.querySelector('.indicator')
const loadstart = () => {
console.log('LEL');
}
const loadstop = () => {
$('#webview-url').val(webview.getURL());
console.log('stop');
}
$('#webviewload').click(()=>{
var url = $('#webview-url').val();
webview.loadURL(url)
})
$('#webviewdownload').click(()=>{
var url = $('#webview-url').val();
$.post( "http://127.0.0.1:54167/download?url="+encodeURI(url),function() {
});
})
webview.addEventListener('did-start-loading', loadstart)
webview.addEventListener('did-stop-loading', loadstop)
});
</script>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="info"> <div role="tabpanel" class="tab-pane fade" id="info">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -134,6 +179,7 @@
<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> </div>
</div> </div>
</div> </div>
</div> </div>
@ -148,7 +194,7 @@
</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(); require('remote').getCurrentWindow().toggleDevTools();
} else if (e.which === 116) { } else if (e.which === 116) {

View File

@ -1,7 +1,8 @@
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');
var libsx = { var libsx = {
@ -27,6 +28,7 @@ ipcMain
break; break;
default: default:
} }
for (var lib in libsx) { for (var lib in libsx) {
if (fs.existsSync(global.dir+"/lib/"+libsx[lib])) { if (fs.existsSync(global.dir+"/lib/"+libsx[lib])) {
@ -41,6 +43,8 @@ ipcMain
if(url === ''){ if(url === ''){
libs.checkNext('youtube-dl'); libs.checkNext('youtube-dl');
}else{ }else{
switch(process.platform){
case "win32":
libs.download(url,"ffmpeg",function(data,file){ libs.download(url,"ffmpeg",function(data,file){
fs.createReadStream(file) fs.createReadStream(file)
.pipe(unzip.Parse()) .pipe(unzip.Parse())
@ -61,6 +65,43 @@ ipcMain
} }
}); });
}); });
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) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
var folder = "";
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)=>{
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;
default:
}
} }
}else{ }else{
libs.checkNext('youtube-dl'); libs.checkNext('youtube-dl');
@ -86,7 +127,7 @@ libs.ff = (os)=>{
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": case "linux":
url = '' url = 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz'
default: default:
@ -104,8 +145,11 @@ libs.yt_dl = (os,cb)=>{
}) })
break; break;
case "linux": case "linux":
url = '' url = 'https://yt-dl.org/downloads/latest/youtube-dl'
libs.download(url,"youtube-dl",function(data,file){
fs.renameSync(file,global.dir+'/lib/youtube-dl');
cb(); cb();
})
default: default:
} }
@ -133,6 +177,8 @@ libs.download = (url,data,cb)=>{
}); });
} }
function win_ffmpeg(){
}
module.exports = libs; module.exports = libs;

View File

@ -1,12 +1,20 @@
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')
module.exports = ()=>{ module.exports = ()=>{
switch(process.platform){
case 'win32':
let tray = new Tray(global.dir+'/app.ico') break;
case 'linux':
break;
}
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') }},

1
src/tmp/inst Normal file
View File

@ -0,0 +1 @@
out