Compare commits

...

5 Commits
master ... dev

Author SHA1 Message Date
7f6f74f50b 1.5.4 2018-03-21 23:43:29 +01:00
c569c0beca 1.5.3 2017-10-08 23:21:55 +02:00
6a3d4820c1 Auto stash before merge of "dev" and "origin/dev" 2017-10-01 16:09:10 +02:00
Luca Jäntsch
3d5d5320bd 1.5.2 2017-10-01 16:09:10 +02:00
43fa503dcf Rebase 2017-10-01 16:08:04 +02:00
22 changed files with 17128 additions and 637 deletions

2
.gitignore vendored
View File

@ -71,3 +71,5 @@ out
*.mp3
*.part
*.ytdl
*.webm

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

@ -1,3 +1,4 @@
const shared = require(global.__dirname + '/../js/shared');
$(function() {
const Config = require('electron-config');
const config = new Config();
@ -7,11 +8,11 @@ $(function() {
var download_progress = $('#download-progress');
var format = "mp3";
if(typeof config.get('format') !== 'undefined'){
if (typeof config.get('format') !== 'undefined') {
format = config.get('format');
}
var path = "";
if(typeof config.get('path') !== 'undefined'){
if (typeof config.get('path') !== 'undefined') {
path = config.get('path');
}
var out = $('#output');
@ -93,7 +94,7 @@ $(function() {
});
}
})
$('body').delegate('#navigota li','click',function(){
$('body').delegate('#navigota li', 'click', function() {
console.log('TEST')
$('#togmenu').click();
})
@ -147,7 +148,17 @@ $(function() {
var YT = JSON.parse(body);
$(
`<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 + `">
<h5 class="mt-0">` + YT.title + `</h5>
Author: ` + YT.author_name + `
@ -171,7 +182,7 @@ $(function() {
$(
`<div class="media">
<div class="d-flex alogn-self-start mr-3" style="
background:url(`+YT.thumbnail_url+`);
background:url(` + YT.thumbnail_url + `);
width: 189px;
height: 104px;
background-size: 189px;
@ -195,7 +206,8 @@ $(function() {
cache[video_id] = YT.title;
ipcRenderer.send('start-download', {
url: $('#url').val(),
id: video_id
id: video_id,
title: helper.replace(YT.title)
});
})
}
@ -214,10 +226,14 @@ $(function() {
function getCommandLine() {
switch (process.platform) {
case 'darwin' : return 'open';
case 'win32' : return 'start';
case 'win64' : return 'start';
default : return 'xdg-open';
case 'darwin':
return 'open';
case 'win32':
return 'start';
case 'win64':
return 'start';
default:
return 'xdg-open';
}
}
})

View File

@ -1,3 +1,4 @@
const shared = require(global.__dirname+'/../js/shared');
$(function() {
const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('pot_real_open', {x:"xx"});
@ -20,6 +21,4 @@ $(function() {
$('body').on( "mouseenter",function () {
$('.navbar').css('opacity',"1")
});
})

13
src/app/js/shared.js Normal file
View File

@ -0,0 +1,13 @@
var shared = {};
var test = "";
shared.setLog = (text)=>{
test = text;
}
shared.log = ()=>{
console.log(test);
}
module.exports = shared;

View File

@ -17,38 +17,38 @@
body {
margin: 0;
background: #333;
}
}
@keyframes arrow-spin {
@keyframes arrow-spin {
100% {
transform: rotate(179deg);
}
}
}
@-webkit-keyframes arrow-spin {
@-webkit-keyframes arrow-spin {
100% {
-webkit-transform: rotate(179deg);
}
}
}
.psoload,
.psoload *,
.psoload *:before,
.psoload *:after {
.psoload,
.psoload *,
.psoload *:before,
.psoload *:after {
box-sizing: border-box;
transition: all 0.3s;
-webkit-transition: all 0.3s;
}
}
.psoload {
.psoload {
position: relative;
margin: 30px auto;
height: 150px;
width: 150px;
}
}
.psoload .straight,
.psoload .curve {
.psoload .straight,
.psoload .curve {
position: absolute;
top: 17.5%;
left: 17.5%;
@ -57,30 +57,30 @@
border-radius: 100%;
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:after {
.psoload .straight:before,
.psoload .straight:after {
content: '';
position: absolute;
width: 15%;
border-bottom: 3px solid #eee;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
}
.psoload .straight:before {
.psoload .straight:before {
top: 5px;
left: 5px;
}
}
.psoload .straight:after {
.psoload .straight:after {
bottom: 5px;
right: 5px;
}
}
.psoload .curve:before,
.psoload .curve:after {
.psoload .curve:before,
.psoload .curve:after {
content: '';
position: absolute;
width: 45px;
@ -89,21 +89,21 @@
border-top-color: #eee;
border-radius: 50%/10px 10px 0 0;
z-index: 90001;
}
}
.psoload .curve:before {
.psoload .curve:before {
transform: rotate(-63deg) translateX(-27px) translateY(-4px);
-webkit-transform: rotate(-63deg) translateX(-27px) translateY(-4px);
}
}
.psoload .curve:after {
.psoload .curve:after {
bottom: 5px;
right: 5px;
transform: rotate(115deg) translateX(-26px) translateY(-12px);
-webkit-transform: rotate(115deg) translateX(-26px) translateY(-12px);
}
}
.psoload .center {
.psoload .center {
position: absolute;
top: 20%;
left: 20%;
@ -111,9 +111,9 @@
height: 60%;
border-radius: 100%;
border: 3px solid #eee;
}
}
.psoload .inner {
.psoload .inner {
position: absolute;
top: 25%;
left: 25%;
@ -122,10 +122,10 @@
border-radius: 100%;
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:after {
.psoload .inner:before,
.psoload .inner:after {
content: '';
position: absolute;
width: 0;
@ -133,31 +133,32 @@
border: 6px solid transparent;
border-bottom-width: 11px;
border-bottom-color: #eee;
}
}
.psoload .inner:before {
.psoload .inner:before {
top: 12px;
left: 12px;
transform: rotate(128deg);
-webkit-transform: rotate(128deg);
}
}
.psoload .inner:after {
.psoload .inner:after {
bottom: 12px;
right: 12px;
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>
</head>
@ -169,37 +170,38 @@
<div class="center"></div>
<div class="inner"></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/>
<div class="progress">
<div class="progress-bar" id="main"></div>
<div class="progress-bar" id="single"></div>
</div>
<script>
$(function(){
$(function() {
var start = [
"whbex",
"wf0jb",
"ulak9",
"wcmxa",
"wc5e2"
"wc5e2",
"xza2z"
];
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')
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')
const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('download-lib', {});
ipcRenderer.on('progress', function(event, arg) {
console.log(arg); // prints "pong"
$('#single').css("width",arg.percent+"%");
}).on('fin-loading',function(event,arg){
$('#main').css("width","100%");
setTimeout(function(){
$('#single').css("width", arg.percent + "%");
}).on('fin-loading', function(event, arg) {
$('#main').css("width", "100%");
setTimeout(function() {
ipcRenderer.send('start-full', {});
},1000)
}, 1000)
})
})
</script>
</body>
</html>

View File

@ -8,19 +8,14 @@
module = undefined;
}
</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.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/bootstrap/bootstrap.min.js"></script>
<script src="./../js/player.js"></script>
<meta charset="utf-8">
<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/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="./../style/bootstrap.min.css" />
<link rel="stylesheet" href="./../style/style.css" />
<link rel="stylesheet" href="./../style/player.css" />
@ -33,7 +28,9 @@
<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="#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>
</div>
</div>
</div>
@ -48,13 +45,14 @@
</nav>
<div class="row">
<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="#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>
</div>
</div>
<div class="col-md-12" >
<div class="col-md-12">
<div style="max-width:380px;margin:auto;margin-bottom:25px;">
<div style=" margin: 0;
@ -98,6 +96,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item format" href="#" data-format="mp3">MP3</a>
<a class="dropdown-item format" href="#" data-format="vorbis">OGG</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item format" href="#" data-format="mp4">MP4</a>
</div>
@ -127,13 +126,72 @@
</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(){
require('remote').getCurrentWindow().toggleDevTools();
const webview = document.querySelector('webview')
const indicator = document.querySelector('.indicator')
const loadstart = () => {
}
const loadstop = () => {
$('#webview-url').val(webview.getURL());
}
$('#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 class="row">
<div class="col-md-12">
<h1>Info</h1>
<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>
@ -148,9 +206,10 @@
</div>
<script src="./../js/app.js"></script>
<script>
document.addEventListener("keydown", function (e) {
document.addEventListener("keydown", function(e) {
if (e.which === 123) {
require('remote').getCurrentWindow().toggleDevTools();
} else if (e.which === 116) {
location.reload();
}

View File

@ -0,0 +1,109 @@
const request = require('request');
// https://vivo.sx/46b5f0d914
var vivo = (url,cb)=>{
request('https://vivo.sx/76aa530aac', function(error, response, body) {
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('body:', body); // Print the HTML for the Google homepage.
var html = body;
var bse64 = html.split('Core.InitializeStream (\'')[1].split('\');')[0];
console.log(bse64)
var arr = eval(Base64.decode(bse64));
console.log(arr[0])
cb(arr[0]);
});
}
module.exports = vivo;
var Base64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode: function(e) {
var t = "";
var n, r, i, s, o, u, a;
var f = 0;
e = Base64._utf8_encode(e);
while (f < e.length) {
n = e.charCodeAt(f++);
r = e.charCodeAt(f++);
i = e.charCodeAt(f++);
s = n >> 2;
o = (n & 3) << 4 | r >> 4;
u = (r & 15) << 2 | i >> 6;
a = i & 63;
if (isNaN(r)) {
u = a = 64
} else if (isNaN(i)) {
a = 64
}
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a)
}
return t
},
decode: function(e) {
var t = "";
var n, r, i;
var s, o, u, a;
var f = 0;
e = e.replace(/[^A-Za-z0-9+/=]/g, "");
while (f < e.length) {
s = this._keyStr.indexOf(e.charAt(f++));
o = this._keyStr.indexOf(e.charAt(f++));
u = this._keyStr.indexOf(e.charAt(f++));
a = this._keyStr.indexOf(e.charAt(f++));
n = s << 2 | o >> 4;
r = (o & 15) << 4 | u >> 2;
i = (u & 3) << 6 | a;
t = t + String.fromCharCode(n);
if (u != 64) {
t = t + String.fromCharCode(r)
}
if (a != 64) {
t = t + String.fromCharCode(i)
}
}
t = Base64._utf8_decode(t);
return t
},
_utf8_encode: function(e) {
e = e.replace(/rn/g, "n");
var t = "";
for (var n = 0; n < e.length; n++) {
var r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r)
} else if (r > 127 && r < 2048) {
t += String.fromCharCode(r >> 6 | 192);
t += String.fromCharCode(r & 63 | 128)
} else {
t += String.fromCharCode(r >> 12 | 224);
t += String.fromCharCode(r >> 6 & 63 | 128);
t += String.fromCharCode(r & 63 | 128)
}
}
return t
},
_utf8_decode: function(e) {
var t = "";
var n = 0;
var r = c1 = c2 = 0;
while (n < e.length) {
r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r);
n++
} else if (r > 191 && r < 224) {
c2 = e.charCodeAt(n + 1);
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
n += 2
} else {
c2 = e.charCodeAt(n + 1);
c3 = e.charCodeAt(n + 2);
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
n += 3
}
}
return t
}
}

View File

@ -7,20 +7,20 @@ const fs = require('fs');
var crunch = {};
crunch.session_save = (session)=>{
crunch.session_save = (session) => {
var net = `# Netscape HTTP Cookie File\n
# http://curl.haxx.se/rfc/cookie_spec.html\n
# This is a generated file! Do not edit.\n\n`;
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;
}
if(session[i].expirationDate>old_exp){
if (session[i].expirationDate > old_exp) {
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);
/*fs.writeFile(global.dir+"/tmp/c", net, function(err) {

View File

@ -1,59 +1,65 @@
const request = require('request');
const fs = require('fs')
const ipcMain = require('electron').ipcMain;
const unzip = require('unzip')
const unzip = require('unzip');
const {
spawn
} = require('child_process');
var libsx = {
"ffmpeg":"ffmpeg",
"ffplay":"ffplay",
"ffprobe":"ffprobe",
"youtube-dl":"youtube-dl"
"ffmpeg": "ffmpeg",
"ffplay": "ffplay",
"ffprobe": "ffprobe",
"youtube-dl": "youtube-dl"
}
var libs = {};
libs.listen = null;
libs.libs = null;
ipcMain
.on('download-lib', (event, arg)=>{
.on('download-lib', (event, arg) => {
console.log('TEST')
libs.listen = event;
console.log(`This platform is ${process.platform}`);
switch (process.platform) {
case "win32":
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{
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 ){
if (libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null) {
var z = 0;
var url = libs.ff(process.platform);
if(url === ''){
if (url === '') {
libs.checkNext('youtube-dl');
}else{
libs.download(url,"ffmpeg",function(data,file){
} else {
switch (process.platform) {
case "win32":
libs.download(url, "ffmpeg", function(data, file) {
fs.createReadStream(file)
.pipe(unzip.Parse())
.on('entry', function (entry) {
.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]));
entry.pipe(fs.createWriteStream(global.dir + '/lib/' + fileName.split('/')[2]));
console.log('TEST')
z++;
if(z == 3){
if (z == 3) {
libs.checkNext('youtube-dl');
}
} else {
@ -61,78 +67,122 @@ 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;
}
}else{
}).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 {
libs.checkNext('youtube-dl');
}
console.dir(libsx);
})
libs.checkNext = (nxt)=>{
if( libs.libs['youtube-dl'] === null ){
libs.yt_dl(process.platform,function(){
})
libs.checkNext = (nxt) => {
if (libs.libs['youtube-dl'] === null) {
libs.yt_dl(process.platform, function() {
libs.startFull();
});
}else{
} else {
libs.startFull();
}
}
libs.startFull = ()=>{
libs.listen.sender.send('fin-loading',{});
libs.startFull = () => {
libs.listen.sender.send('fin-loading', {});
}
libs.ff = (os)=>{
libs.ff = (os) => {
var url = "";
switch (os) {
case "win32":
url = 'http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip';
break;
case "linux":
url = ''
url = 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz'
default:
}
return url;
}
libs.yt_dl = (os,cb)=>{
libs.yt_dl = (os, cb) => {
var url = "";
switch (os) {
case "win32":
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');
libs.download(url, "youtube-dl", function(data, file) {
fs.renameSync(file, global.dir + '/lib/youtube-dl.exe');
cb();
})
break;
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();
})
default:
}
}
libs.download = (url,data,cb)=>{
libs.download = (url, data, cb) => {
var r = request(url);
var actual = 1;
var full = 100;
var perc = 0;
r.on('data', function (chunk) {
r.on('data', function(chunk) {
actual += chunk.length;
perc = actual / full * 100;
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) {
res.pipe(fs.createWriteStream(global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]));
full = res.headers[ 'content-length' ] ;
res.on('end', function () {
cb(data,global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]);
r.on('response', function(res) {
res.pipe(fs.createWriteStream(global.dir + '/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]));
full = res.headers['content-length'];
res.on('end', function() {
cb(data, global.dir + '/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]);
})
});
}
function win_ffmpeg() {
}
module.exports = libs;

View File

@ -1,4 +1,6 @@
const { exec } = require('child_process');
const {
exec
} = require('child_process');
var install = {};
@ -6,13 +8,13 @@ var install = {};
install.init = (cb)=>{
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']
['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){
var download = (i) => {
install.download(url[i], function(path) {
switch (i) {
case 0:
shell.
@ -22,31 +24,33 @@ install.init = (cb)=>{
}
if(i<url.length-1){
if (i < url.length - 1) {
download(i++);
}else{
} else {
cb();
}
})
};
download(0)
}
install.download = (url,cb) =>{
install.download = (url, cb) => {
var r = request(url);
var actual = 1;
var full = 100;
var perc = 0;
r.on('data', function (chunk) {
r.on('data', function(chunk) {
actual += chunk.length;
perc = actual / full * 100;
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 ));
full = res.headers[ 'content-length' ] ;
res.on('end', function () {
});
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

@ -15,36 +15,40 @@ var s = null;
var pot_open_ev = null;
ipcMain
.on('close_pot',(event,arg)=>{
.on('close_pot', (event, arg) => {
console.log('CLOSE')
pot.close(event);
})
.on('pot_run',(event,arg)=>{
pot_open_ev.sender.send('pot_play',arg);
})
})
.on('pot_run', (event, 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')
pot_open_ev = event;
})
.on('open-pot',(event,arg)=>{
})
.on('open-pot', (event, arg) => {
pot.open(event);
})
})
pot.isOpen = false;
pot.open = (e) => {
s = e;
if (win !== null) {
e.sender.send('play-in-Window',{do :false});
e.sender.send('play-in-Window', {
do: false
});
win.close();
}
var x = new playerOnTop(e);
}
pot.close = ()=>{
pot.close = () => {
console.log('CLOSE')
s.sender.send('play-in-Window',{do :false});
s.sender.send('play-in-Window', {
do: false
});
win.close();
}
@ -60,21 +64,25 @@ class playerOnTop {
alwaysOnTop: true,
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.loadURL(`file://${global.dir}/app/view/pot.html`)
win.once('ready-to-show', () => {
win.show();
})
win.on('resize', function () {
setTimeout(function () {
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});
e.sender.send('play-in-Window', {
do: false
});
win = null;
});
}

View File

@ -1,20 +1,41 @@
const {app, Menu, Tray} = require('electron')
const {
app,
Menu,
Tray
} = require('electron')
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')
const contextMenu = Menu.buildFromTemplate([
{label: 'Open', click(){ main_window.open() }},
break;
case 'linux':
break;
}
let tray = new Tray(path.join(global.dir + '/app.png'))
const contextMenu = Menu.buildFromTemplate([{
label: 'Open',
click() {
main_window.open()
}
},
/*{label: 'About',click() { console.log('item 1 clicked') }},
{label: 'Item1', type: 'radio'},
{type: 'separator'},
{label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},*/
{label: 'Beenden', click() { main_window.close(); }},
{
label: 'Beenden',
click() {
main_window.close();
}
},
])
tray.setToolTip('Cyb3r Downloader.')
tray.setContextMenu(contextMenu)

View File

@ -6,9 +6,9 @@ const ipcMain = require('electron').ipcMain;
var watch_event = null;
ipcMain
.on('watchr_event', (event, arg)=>{
.on('watchr_event', (event, arg) => {
watch_event = event
})
})
class folderWatchr {
constructor(folder) {
@ -20,9 +20,12 @@ class folderWatchr {
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]});
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) {
@ -36,10 +39,16 @@ class folderWatchr {
console.log('the file', fullPath, 'was created', currentStat)
files.push(fullPath);
watch_event.sender.send('watchr_file',{type:"add",file:fullPath});
watch_event.sender.send('watchr_file', {
type: "add",
file: fullPath
});
break;
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);
break;
}
@ -51,9 +60,9 @@ class folderWatchr {
}
// 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()
}
}

View File

@ -3,7 +3,7 @@ var cors = require('cors')
app.use(cors())
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
extended: true
}));

View File

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

View File

@ -1,5 +1,10 @@
const { spawn } = require('child_process');
const {Notification,ipcMain}= require('electron');
const {
spawn
} = require('child_process');
const {
Notification,
ipcMain
} = require('electron');
const dl_routine = require('./youtube-dl.routine')
const nodeID3 = require('node-id3');
@ -15,71 +20,83 @@ var format = "mp3";
var fol = null;
var pot_open_ev = null;
var request = require('request').defaults({ encoding: null });
var request = require('request').defaults({
encoding: null
});
var list = [];
ipcMain
.on('start-download', (event, arg)=>{
path = orig_path
var download = new yt_dl(arg.url,arg.id);
.on('start-download', (event, arg) => {
path = orig_path;
if(list.length != 0){
list.push([arg,event]);
}else{
list.push([arg,event]);
var download = new yt_dl(arg.url, arg.id, arg.title);
download.addListen(event)
download.download();
})
.on('set-format',(event,arg)=>{
}
})
.on('set-format', (event, arg) => {
format = arg.format;
})
.on('start-download-pl', (event, arg)=>{
})
.on('start-download-pl', (event, arg) => {
var mkdirp = require('mkdirp');
if(orig_path === ""){
if (orig_path === "") {
path = '.'
}else{
} else {
path = orig_path
}
mkdirp(path+'/'+arg.folder, function(err) {
path = path+'/'+arg.folder;
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);
var download = new yt_dl(arg.url, arg.id);
download.addListen(event)
download.download();
});
})
.on('setPath', function(event, arg) {
})
.on('setPath', function(event, arg) {
path = arg.path;
orig_path = arg.path;
if(fol !== null){
if (fol !== null) {
fol.destroy()
}
fol = new folderWatchr(path);
console.log('SET Path: '+path)
});
console.log('SET Path: ' + path)
});
var yt_dl = class{
constructor(url,id){
this.url = url ;
var yt_dl = class {
constructor(url, id, title) {
this.url = url;
this.percent = 0;
this.lwrite = null;
this.id = id;
this.title = title
}
addListen(e){
addListen(e) {
this.lwrite = e
}
status(stat){
status(stat) {
this.lwrite('download-progress', stat);
}
download(){
download() {
var log = [];
var me = this;
var ls;
var m = dl_routine(path,this.url,format);
ls = spawn(m[0],m[1]);
var m = dl_routine(path, this.url, format, this.title);
console.log('CMD: '+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]);
}else{
} else {
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url,'-o',path+'/%(title)s.%(ext)s']);
}
@ -87,38 +104,44 @@ var yt_dl = class{
data = data.toString('utf8');
log.push(data);
//console.log(data);
try{
var z = data.replace(/(\r\n|\n|\r)/gm,"").split(' ');
try {
var z = data.replace(/(\r\n|\n|\r)/gm, "").split(' ');
console.log(z)
switch (z[0]) {
case '[download]':
var percent = data.split(']')[1].split('of')[0];
//console.log(z)
me.percent = percent.trim();
me.lwrite.sender.send('download-progress',{percent :me.percent,id:me.id});
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'){
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++){
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'){
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});
me.lwrite.sender.send('file', {
id: me.id,
file: file
});
break;
}
}
}
}catch(e){
} catch (e) {
console.log(e);
}finally{
} finally {
}
});
@ -127,41 +150,59 @@ var yt_dl = class{
});
ls.on('close', (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('process-fin',{percent :me.percent,id:me.id});
me.lwrite.sender.send('file', {
id: me.id,
file: log[log.length - 2].split('[ffmpeg] Destination: ')[1]
});
me.lwrite.sender.send('process-fin', {
percent: me.percent,
id: me.id
});
list.splice(0,1);
if(list.length>0){
dl(list[0][0],list[0][1]);
}
var title = this.title;
if(this.url.match('youtube')){
if (this.url.match('youtube') && format === 'mp3') {
var url = this.url;
var video_id = this.url.split('v=')[1];
var ampersandPosition = video_id.indexOf('&');
if (ampersandPosition != -1) {
video_id = video_id.substring(0, ampersandPosition);
}
/*
var fornoti = title;
if (title === "") {
fornoti = url;
}
var x = new Notification({
title:"Cyb3r Downloader",
body :"finished download for "+url,
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) {
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 = {
var tags = {
image: body
}
var success = nodeID3.write(tags, log[log.length-2].split('[ffmpeg] Destination: ')[1]);
console.log(success);*/
//});
var success = nodeID3.write(tags, path + '/' + title + '.' + format);
console.log(success);
});
}
});
}
}
function dl(arg,event){
var download = new yt_dl(arg.url, arg.id, arg.title);
download.addListen(event)
download.download();
}
module.exports = yt_dl;

View File

@ -1,30 +1,29 @@
module.exports = (path,url,format)=>{
var command = global.dir+'/lib/youtube-dl';
module.exports = (path, url, format, title = "%(title)s") => {
var command = global.dir + '/lib/youtube-dl';
var param = [];
console.log(url);
if(url.match('youtube')){
if (url.match('youtube')) {
console.log('youtube')
switch (format) {
case "vorbis":
param = ['-x', '-f', 'bestaudio[acodec^=opus]', '--audio-format', 'vorbis', '-i', url, '-o', path + '/'+title+'.%(ext)s'];
break;
case "mp3":
param = ['-x','--audio-format','mp3','-i',url,'-o',path+'/%(title)s.%(ext)s'];
param = ['--audio-quality', '0','-f','bestaudio[ext=m4a]','--audio-format','mp3', url, '-o', path + '/'+title+'.%(ext)s'];
break;
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;
default:
}
}
else if(url.match('crunchyroll')){
} else if (url.match('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')) {
fs.writeFileSync(global.dir+'/tmp/inst',"out");
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{
var win ;
app.getPath('documents')
@ -56,8 +33,6 @@ if (!fs.existsSync(global.dir+'/tmp/inst')) {
})
ipcMain
.on('start-full', (event, arg)=>{
//main_window.createWindow();
//main_window.open();
tray_win = tray();
@ -67,27 +42,18 @@ if (!fs.existsSync(global.dir+'/tmp/inst')) {
win.loadURL(`file://${__dirname}/app/view/init.html`)
win.once('ready-to-show', () => {
win.show()
//var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4")
//x.download();
})
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;
});
}
app.on('ready', createWindow);
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') {
app.quit();
}
});
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) {
createWindow();
}

1
src/tmp/inst Normal file
View File

@ -0,0 +1 @@
out