1.4.0 Alpha

This commit is contained in:
Theenoro 2017-08-28 23:44:29 +02:00
commit 12db3c4599
20 changed files with 851 additions and 146 deletions

View File

@ -3,6 +3,9 @@
![./current-preview.PNG](./current-preview.PNG)
# v 1.4.0 Alpha
Preview [Video](https://cl.thee.moe/index.php/s/T8FEaFFxyhlxIj6)
# Download 1.3.0

View File

@ -49,9 +49,12 @@
"dependencies": {
"electron": "^1.6.11",
"electron-compile": "^6.4.1",
"fs": "0.0.1-security",
"mkdirp": "^0.5.1",
"path": "^0.12.7",
"request": "^2.81.0",
"unzip": "^0.1.11"
"unzip": "^0.1.11",
"watchr": "^3.0.1"
},
"devDependencies": {
"babel-plugin-transform-async-to-generator": "^6.24.1",

View File

@ -1,68 +1,130 @@
$(function(){
$(function() {
var download_progress = $('#download-progress');
var format = null;
var out = $('#output');
var video = document.getElementById('video');
const ipcRenderer = require('electron').ipcRenderer;
const request = require('request');
const {dialog} = require('electron').remote;
const helper = require('./../../helper/string');
const {
dialog
} = require('electron').remote;
var cache = {};
var path = "";
var pot = false;
ipcRenderer.send('watchr_event', {});
ipcRenderer.on('play-in-Window',function(event,arg){
pot = arg.do;
})
ipcRenderer.on('watchr_file', function(event, arg) {
arg.file = encodeURI(arg.file)
if (arg.type === "add") {
$('#watchr_files').append('<div class="row-flex file" data-file="' + arg.file + '"><div class="flex-btn"><button class="play-file btn btn-success" data-file="' + 'file://' + arg.file + '"><i class="fa fa-play-circle-o" aria-hidden="true"></i></button></div><div class="cont">' + arg.file + '</div></tr>')
} else if (arg.type === "remove") {
$('.file[data-file="' + arg.file + '"]').remove();
}
$('#download-progress-' + arg.id).html(arg.percent);
})
ipcRenderer.on('download-progress', function(event, arg) {
console.log(arg); // prints "pong"
$('#download-progress-'+arg.id).css("width",arg.percent);
$('#download-progress-'+arg.id).html(arg.percent);
console.log(arg); // prints "pong"
$('#download-progress-' + arg.id).css("width", arg.percent);
$('#download-progress-' + arg.id).html(arg.percent);
});
ipcRenderer.on('process-fin', function(event, arg) {
console.log(arg); // prints "pong"
$('#download-progress-'+arg.id).css("width",arg.percent);
$('#download-progress-'+arg.id).html("CONVERTED");
console.log(arg); // prints "pong"
$('#download-progress-' + arg.id).css("width", arg.percent);
$('#download-progress-' + arg.id).html("CONVERTED");
});
ipcRenderer.on('file', function(event, arg) {
console.log(arg); // prints "pong"
$('#body-'+arg.id).append('<audio src="file://'+path+'/'+cache[arg.id]+'.mp3" controls="true"/>');
console.log('DOWNLOADED')
console.log(arg); // prints "pong"
$('.media-out-' + arg.id).html('<button class="play-file" data-file="' + 'file://' + path + '/' + encodeURI(cache[arg.id]) + '.' + format + '">Play</button>');
//var video = document.getElementById('video');
//$('#body-' + arg.id).append('<audio src="file://' + path + '/' + cache[arg.id] + '.'+format+'" controls="true"/>');
});
document.getElementById('party').addEventListener('click', _ => {
path = dialog.showOpenDialog({
properties: ['openDirectory']
})[0];
console.log(path)
ipcRenderer.send('setPath', {path:path});
path = dialog.showOpenDialog({
properties: ['openDirectory']
})[0];
console.log(path)
ipcRenderer.send('setPath', {
path: path
});
})
$('body').delegate('.format','click',function(e){
ipcRenderer.send('set-format', {format:e.currentTarget.dataset.format});
$('#pot').click(function(){
ipcRenderer.send('open-pot', {
});
});
$('body').delegate('.play-file', 'click', function(e) {
if(pot === false){
video.setAttribute("src", e.currentTarget.dataset.file);
video.play();
}else{
ipcRenderer.send('pot_run', {file:e.currentTarget.dataset.file});
}
})
$('body').delegate('.format', 'click', function(e) {
format = e.currentTarget.dataset.format;
ipcRenderer.send('set-format', {
format: e.currentTarget.dataset.format
});
console.log(e.currentTarget.dataset.format);
})
$('#start-download').click(function(){
var video_id = $('#url').val().split('v=')[1];
var ampersandPosition = video_id.indexOf('&');
if(ampersandPosition != -1) {
video_id = video_id.substring(0, ampersandPosition);
}
var playlist_id = $('#url').val().split('list=')[1];
if(typeof playlist_id !== 'undefined'){
var playlist_idPOS = playlist_id.indexOf('&');
if(playlist_idPOS != -1) {
playlist_id = playlist_id.substring(0, playlist_idPOS);
$('#start-download').click(function() {
var url = $('#url').val();
if (url.match('crunchyroll')) {
var video_id = Math.floor(Date.now() / 1000);
$('<div class="media" ><div class="media-left"><a href="#"><img id="img-' + video_id + '" width="128" class="media-object" src="' + '" alt="..."></a></div><div class="media-body" id="body-' + video_id + '"><h4 class="media-heading">' + url + '</h4> Author: ' + '<div class="progress"><div class="progress-bar" id="download-progress-' + video_id + '" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">0%</div></div><div class="media-out-' + video_id + '"></div></div></div>').prependTo('#output');
ipcRenderer.send('start-download', {
url: $('#url').val(),
id: video_id
});
} else {
var video_id = $('#url').val().split('v=')[1];
var ampersandPosition = video_id.indexOf('&');
if (ampersandPosition != -1) {
video_id = video_id.substring(0, ampersandPosition);
}
var playlist_id = $('#url').val().split('list=')[1];
if (typeof playlist_id !== 'undefined') {
var playlist_idPOS = playlist_id.indexOf('&');
if (playlist_idPOS != -1) {
playlist_id = playlist_id.substring(0, playlist_idPOS);
}
request
.get('https://www.youtube.com/oembed?url=https://www.youtube.com/playlist?list=' + playlist_id + '&format=json', function(err, httpResponse, body) {
var YT = JSON.parse(body);
$('<div class="media" ><div class="media-left"><a href="#"><img id="img-' + video_id + '" width="128" class="media-object" src="' + YT.thumbnail_url + '" alt="..."></a></div><div class="media-body" id="body-' + video_id + '"><h4 class="media-heading">' + YT.title + '</h4> Playlistauthor: ' + YT.author_name + '<div class="progress"><div class="progress-bar" id="download-progress-' + video_id + '" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">0%</div></div><div class="media-out-' + video_id + '"></div></div></div>').prependTo('#output');
cache[video_id] = YT.title;
ipcRenderer.send('start-download-pl', {
url: $('#url').val(),
id: video_id,
folder: YT.author_name + '-' + YT.title.replace(/\|/g, "_")
});
})
} else {
request
.get('https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=' + video_id + '&format=json', function(err, httpResponse, body) {
var YT = JSON.parse(body);
$('<div class="media" ><div class="media-left"><a href="#"><img id="img-' + video_id + '" width="128" class="media-object" src="' + YT.thumbnail_url + '" alt="..."></a></div><div class="media-body" id="body-' + video_id + '"><h4 class="media-heading">' + YT.title + '</h4> Author: ' + YT.author_name + '<div class="progress"><div class="progress-bar" id="download-progress-' + video_id + '" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">0%</div></div><div class="media-out-' + video_id + '"></div></div></div>').prependTo('#output');
cache[video_id] = YT.title;
ipcRenderer.send('start-download', {
url: $('#url').val(),
id: video_id
});
})
}
console.log(playlist_id + ' id:' + video_id)
request
.get('https://www.youtube.com/oembed?url=https://www.youtube.com/playlist?list='+ playlist_id+'&format=json', function(err,httpResponse,body){
var YT = JSON.parse(body);
$( '<div class="media" ><div class="media-left"><a href="#"><img id="img-'+video_id+'" width="128" class="media-object" src="'+YT.thumbnail_url +'" alt="..."></a></div><div class="media-body" id="body-'+video_id+'"><h4 class="media-heading">'+YT.title+'</h4> Playlistauthor: '+YT.author_name+'<div class="progress"><div class="progress-bar" id="download-progress-'+video_id+'" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">0%</div></div></div></div>').prependTo('#output');
cache[video_id] = YT.title;
ipcRenderer.send('start-download-pl', {url:$('#url').val(),id:video_id,folder:YT.author_name+'-'+YT.title});
})
}else{
request
.get('https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v='+ video_id+'&format=json', function(err,httpResponse,body){
var YT = JSON.parse(body);
$( '<div class="media" ><div class="media-left"><a href="#"><img id="img-'+video_id+'" width="128" class="media-object" src="'+YT.thumbnail_url +'" alt="..."></a></div><div class="media-body" id="body-'+video_id+'"><h4 class="media-heading">'+YT.title+'</h4> Author: '+YT.author_name+'<div class="progress"><div class="progress-bar" id="download-progress-'+video_id+'" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">0%</div></div></div></div>').prependTo('#output');
cache[video_id] = YT.title;
ipcRenderer.send('start-download', {url:$('#url').val(),id:video_id});
})
}
console.log(playlist_id+' id:'+video_id)
})
})

46
src/app/js/player.js Normal file
View File

@ -0,0 +1,46 @@
var video;
$(function(){
video = document.getElementById('video');
// btn
var st_play = '<i class="fa fa-play-circle-o" aria-hidden="true"></i>';
var st_pause = '<i class="fa fa-pause-circle-o" aria-hidden="true"></i>';
video.ontimeupdate = function(){
var percentage = ( video.currentTime / video.duration ) * 100;
$("#time span").css("width", percentage+"%");
};
$("#time").on("click", function(e){
var offset = $(this).offset();
var left = (e.pageX - offset.left);
var totalWidth = $("#time").width();
var percentage = ( left / totalWidth );
var vidTime = video.duration * percentage;
video.currentTime = vidTime;
})
$("#volume span").css('width',(100*video.volume)+'%')
$("#volume").on("click", function(e){
var offset = $(this).offset();
var left = (e.pageX - offset.left);
var totalWidth = $("#volume").width();
var percentage = ( left / totalWidth );
var volume = 1 * percentage;
video.volume = volume;
$("#volume span").css('width',(100*percentage)+'%')
console.log(volume)
})
$('#play').click(function(){
if(video.paused){
video.play();
$('#play').html(st_pause)
}else{
video.pause();
$('#play').html(st_play)
}
})
})

25
src/app/js/pot_main.js Normal file
View File

@ -0,0 +1,25 @@
$(function() {
const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('pot_real_open', {x:"xx"});
$('#close').click(function () {
ipcRenderer.send('close_pot',{});
});
ipcRenderer.on('pot_play',function(event,arg){
var file = arg.file;
video.setAttribute("src", file);
video.play();
})
$('.navbar').on( "mouseleave",function () {
$('.navbar').css('opacity',"0")
});
$('.navbar').on( "mouseenter",function () {
$('.navbar').css('opacity',"1")
});
$('body').on( "mouseenter",function () {
$('.navbar').css('opacity',"1")
});
})

38
src/app/style/player.css Normal file
View File

@ -0,0 +1,38 @@
#time {
cursor: pointer;
height: 10px;
margin-bottom: 10px;
outline: thin solid #FFF;
overflow: hidden;
position: relative;
width: 100%;
vertical-align: -webkit-baseline-middle;
line-height: 1.42857143;
height: 9px;
display: inline-block;
top: 13px;
}
#volume {
cursor: pointer;
height: 10px;
margin-bottom: 10px;
outline: thin solid #FFF;
overflow: hidden;
position: relative;
width: 200px;
vertical-align: -webkit-baseline-middle;
line-height: 1.42857143;
height: 9px;
display: inline-block;
top: 13px;
}
#time span, #volume span {
background-color: #FFF;
position: absolute;
top: 0;
left: 0;
height: 10px;
width: 0px;
}

View File

@ -1,59 +1 @@
body {
margin: 0;
background: #131313;
color:#e9188d;
}
.btn-success {
color: #e9188d;
background-color: #131313;
border-color: #e9188d;
transition: all .3s;
}
.btn-success:hover ,.btn-success:active,.btn-success:focus,.dropdown-toggle:focus,.dropdown-toggle:active,.btn-success:active, .btn-success.active, .open > .dropdown-toggle.btn-success {
color: #131313 !important;
background-color: #e9188d !important;
border-color: #e9188d !important;
transition: all .3s;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
text-decoration: none;
color: rgb(233, 24, 141);
background-color: #131313;
}
.dropdown-menu{
background-color: #131313;
}
span.input-group-btn.open > ul > li> a{
background-image:none;
}
.progress{
background-image:none;
background-color: #131313;
box-shadow: inset 0px 0px 3px 0px #da1985;
}
.progress-bar{
background-image:none;
background-color: #131313;
box-shadow: inset 0px 0px 12px 0px #da1985;
}
.media:first-child {
margin-top: 15px;
}
.media {
box-shadow: 0px 0px 6px 1px #ff008e;
}
.sidebar-nav {
padding: 10px;
}
.nav.nav-list a {
padding: 5px 10px;
}
.nav-header {
font-weight: bold;
}
.scroll{
overflow-y: scroll;
height: calc( 100vh - 46px);
}
body{margin:0;margin-top:50px;background:#111;color:#f8f8f8}.btn-success{color:#f8f8f8;background-color:#111;border-color:#f8f8f8;transition:all .3s}.btn-success.active,.btn-success:active,.btn-success:focus,.btn-success:hover,.dropdown-toggle:active,.dropdown-toggle:focus,.open>.dropdown-toggle.btn-success{color:#111!important;background-color:#f8f8f8!important;border-color:#f8f8f8!important;transition:all .3s}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{text-decoration:none;color:#f8f8f8;background-color:#111}.dropdown-menu{background-color:#111}span.input-group-btn.open>ul>li>a{background-image:none}.progress{background-image:none;background-color:#111;box-shadow:inset 0 0 3px 0 #f8f8f8}.progress-bar{background-image:none;background-color:#111;box-shadow:inset 0 0 12px 0 #f8f8f8;transition:.3s all}.media:first-child{margin-top:15px}.media{box-shadow:0 0 6px 1px #f8f8f8}.sidebar-nav{padding:10px}.nav.nav-list a{padding:5px 10px}.nav-header{font-weight:700}.scroll{overflow-y:scroll;height:calc(100vh - 96px)}.left-playlist{box-shadow:0 0 6px 1px #f8f8f8;height:calc(100vh - 20vw - 30px)}.row-flex{word-break:break-all;width:100%;display:flex}.row-flex .flex-btn{width:50px}.row-flex .cont{width:100%}

88
src/app/style/style.less Normal file
View File

@ -0,0 +1,88 @@
/*
*/
@main-front-color : #f8f8f8;
@background-color : #111111;
@background-2ndcolor: #232323;
body {
margin: 0;
margin-top: 50px;
background: @background-color;
color:@main-front-color;
}
.btn-success {
color: @main-front-color;
background-color: @background-color;
border-color: @main-front-color;
transition: all .3s;
}
.btn-success:hover ,.btn-success:active,.btn-success:focus,.dropdown-toggle:focus,.dropdown-toggle:active,.btn-success:active, .btn-success.active, .open > .dropdown-toggle.btn-success {
color: @background-color !important;
background-color: @main-front-color !important;
border-color: @main-front-color !important;
transition: all .3s;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
text-decoration: none;
color: @main-front-color;
background-color: @background-color;
}
.dropdown-menu{
background-color: @background-color;
}
span.input-group-btn.open > ul > li> a{
background-image:none;
}
.progress{
background-image:none;
background-color: @background-color;
box-shadow: inset 0px 0px 3px 0px @main-front-color;
}
.progress-bar{
background-image:none;
background-color: @background-color;
box-shadow: inset 0px 0px 12px 0px @main-front-color;
transition: .3s all;
}
.media:first-child {
margin-top: 15px;
}
.media {
box-shadow: 0px 0px 6px 1px @main-front-color;
}
.sidebar-nav {
padding: 10px;
}
.nav.nav-list a {
padding: 5px 10px;
}
.nav-header {
font-weight: bold;
}
.scroll{
overflow-y: scroll;
height: ~"calc( 100vh - 96px)";
}
.left-playlist{
box-shadow: 0px 0px 6px 1px @main-front-color;
height: ~"calc(100vh - 20vw - 30px )";
}
.row-flex{
word-break: break-all;
width:100%;
display: flex;
.flex-btn{
width: 50px;
}
.cont{
width:100%;
}
}

View File

@ -10,7 +10,7 @@
</script>
<script src="./../libs/jquery/jquery-3.2.1.min.js"></script>
<script src="./../libs/bootstrap/js/bootstrap.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" />
@ -18,6 +18,7 @@
<link rel="stylesheet" href="./../libs/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="./../style/progress.css" />
<link rel="stylesheet" href="./../style/style.css" />
<link rel="stylesheet" href="./../style/player.css" />
</head>
<body>
@ -25,42 +26,74 @@
<div class="row">
<div class="col-md-2">
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Navigation</li>
<li class="active"><a href=""><i class="fa fa-download" aria-hidden="true"></i> Downloader</a></li>
<li><a href="#"><i class="fa fa-play-circle-o" aria-hidden="true"></i> Player</a></li>
</ul>
<ul class="nav nav-tabs nav-pills nav-stacked" role="tablist">
<li role="presentation" class="active"><a href="#download" aria-controls="download" role="tab" data-toggle="tab">Download</a></li>
<li role="presentation"><a href="#player" aria-controls="player" role="tab" data-toggle="tab">Player</a></li>
</ul>
</div>
</div>
<dic class="col-md-10">
<input id="business" type="file" style="display: none" />
<div class="row">
<div class="col-md-12">
<div class="input-group input-group-lg">
<span class="input-group-btn">
<button id="party" class="very-sweet-looking btn btn-success btn-sm">Select Folder</button>
</span>
<input type="text" class="form-control input-sm" maxlength="128" id="url" placeholder="YT-Url" />
<span class="input-group-btn">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Format <span class="caret"></span>
</button>
<ul class="dropdown-menu" id="format">
<li><a href="#" class="format" data-format="mp3">MP3</a></li>
<li role="separator" class="divider"></li>
<li><a href="#" class="format" data-format="mp4">MP4</a></li>
</ul>
</span>
<span class="input-group-btn">
<button type="button" id="start-download" class="btn btn-success btn-sm">Download</button>
</span>
<div class="col-md-6">
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="download">
<input id="business" type="file" style="display: none" />
<div class="row">
<div class="col-md-12">
<div class="input-group input-group-lg">
<span class="input-group-btn">
<button id="party" class="very-sweet-looking btn btn-success btn-sm">Select Folder</button>
</span>
<input type="text" class="form-control input-sm" maxlength="128" id="url" placeholder="YT-Url" />
<span class="input-group-btn">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Format <span class="caret"></span>
</button>
<ul class="dropdown-menu" id="format">
<li><a href="#" class="format" data-format="mp3">MP3</a></li>
<li role="separator" class="divider"></li>
<li><a href="#" class="format" data-format="mp4">MP4</a></li>
</ul>
</span>
<span class="input-group-btn">
<button type="button" id="start-download" class="btn btn-success btn-sm">Download</button>
</span>
</div>
</div>
</div>
<div class="row scroll">
<div class="col-md-12" id="output">
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="player">
<div class="row">
<div class="col-md-12">
<div id="watchr_files">
</div>
</div>
</div>
</div>
</div>
<div class="row scroll">
<div class="col-md-12" id="output">
</div>
<div class="col-md-4">
<div class="embed-responsive embed-responsive-16by9">
<video id="video"></video>
</div>
<div style=" margin: 0; padding: 0; height: 35px; display:flex;">
<button class="btn nabbar-btn btn-success" style="margin:0;" id="play"><i class="fa fa-pause-circle-o" aria-hidden="true"></i></button>
<div id="time">
<span></span>
</div>
<button class="btn nabbar-btn btn-success" style="margin:0;"><i class="fa fa-volume-up" aria-hidden="true"></i></button>
<div id="volume">
<span></span>
</div>
<button class="btn navbar-btn btn-success" id="pot" style="margin:0;"><i class="fa fa-window-restore" aria-hidden="true"></i></button>
</div>
<div class="left-playlist">
</div>
</div>
</div>

77
src/app/view/pot.html Normal file
View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<script>
if (typeof module === 'object') {
window.module = module;
module = undefined;
}
</script>
<script src="./../libs/jquery/jquery-3.2.1.min.js"></script>
<script src="./../libs/bootstrap/js/bootstrap.js"></script>
<script src="./../js/player.js"></script>
<meta charset="utf-8">
<title>Cyb3r Downloader - Player on Top</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/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="./../style/progress.css" />
<link rel="stylesheet" href="./../style/style.css" />
<link rel="stylesheet" href="./../style/player.css" />
<style>
video {
max-width: 100%;
width:100%;
max-height: 100%;
}
body{
overflow:hidden;
}
body > nav > div > button {
margin: 0;
background-color: transparent !important;
}
.navbar{
padding: 0;
margin: 0;
height: 35px;
min-height: 35px;
width:100%;
}
body .navbar{
opacity: 0;
transition: .3s all;
position: fixed;
}
body:hover .navbar{
opacity: 1;
transition: .3s all;
background-color: rgba(51, 51, 51, 0.64);
box-shadow: 5px 0px 6px 6px rgba(51, 51, 51, 0.64);
}
</style>
</head>
<body style="margin:0">
<nav class="navbar navbar-static-top">
<div style=" margin: 0; padding: 0; height: 35px; display:flex;">
<button class="btn nabbar-btn btn-success" style="margin:0;" id="play"><i class="fa fa-pause-circle-o" aria-hidden="true"></i></button>
<div id="time">
<span></span>
</div>
<button class="btn nabbar-btn btn-success" style="margin:0;" ><i class="fa fa-volume-up" aria-hidden="true"></i></button>
<div id="volume">
<span></span>
</div>
<button class="btn navbar-btn btn-success" style="-webkit-app-region: drag;margin: 0;"><i class="fa fa-arrows" aria-hidden="true"></i></button>
<button class="btn navbar-btn btn-success" id="close" style="margin:0;"><i class="fa fa-window-close-o" aria-hidden="true"></i></button>
</div>
</nav>
<video id="video"></video>
<script src="./../js/pot_main.js"></script>
</body>
</html>

View File

@ -0,0 +1,34 @@
/*
JUST TO WATCH OFFLINE
*/
const fs = require('fs');
var crunch = {};
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++){
if(typeof session[i].expirationDate == 'undefined'){
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';
}
//console.log(net);
/*fs.writeFile(global.dir+"/tmp/c", net, function(err) {
if(err) {
return console.log(err);
}
//console.log("T!");
});*/
}
module.exports = crunch;

View File

@ -0,0 +1,82 @@
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);
})
.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;
})
.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});
win.close();
}
var x = new playerOnTop(e);
}
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: 180,
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();
})
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;
});
}
}
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

@ -0,0 +1,38 @@
const {
BrowserWindow,
session
} = require('electron');
const crunch = require('./../crunchyroll')
class browser {
constructor(url){
console.log("TEST")
this.window = new BrowserWindow({
width: 500,
height: 500,
show: true,
frame: true,
icon: global.dir + '/app.ico'
})
setInterval(function(){
session.defaultSession.cookies.get({url:'http://crunchyroll.com'}, (error, cookies) => {
//console.log(error, cookies)
crunch.session_save(cookies);
})
},3000)
var window = this.window
window.loadURL(url)
window.once('ready-to-show', () => {
})
this.window.on('closed', () => {
window = null;
});
}
}
module.exports = browser;

View File

@ -1,11 +1,17 @@
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('start-download', (event, arg)=>{
path = orig_path
@ -31,9 +37,13 @@ ipcMain
download.download();
});
})
ipcMain.on('setPath', function(event, arg) {
.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)
});
@ -54,16 +64,9 @@ var yt_dl = class{
var log = [];
var me = this;
var ls;
switch (format) {
case "mp3":
ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url,'-o',path+'/%(title)s.%(ext)s']);
break;
case "mp4":
ls = spawn(global.dir+'/lib/youtube-dl', ['-f','bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',this.url,'-o',path+'/%(title)s.%(ext)s']);
break;
default:
}
var m = dl_routine(path,this.url,format);
ls = spawn(m[0],m[1]);
if(path == ''){
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url]);
}else{
@ -85,7 +88,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

@ -0,0 +1,31 @@
module.exports = (path,url,format)=>{
var command = global.dir+'/lib/youtube-dl';
var param = [];
console.log(url);
if(url.match('youtube')){
console.log('youtube')
switch (format) {
case "mp3":
param = ['-x','--audio-format','mp3','-i',url,'-o',path+'/%(title)s.%(ext)s'];
break;
case "mp4":
param = ['-w','-f','bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',url,'-o',path+'/%(title)s.%(ext)s'];
break;
default:
}
}
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'];
}
return [command,param];
}

15
src/helper/string.js Normal file
View File

@ -0,0 +1,15 @@
var st = {};
st.replace = (str)=>{
return sub
.replace(/\|/g, "_");
}
module.exports = st;

View File

@ -10,11 +10,15 @@ const {
const fs = require('fs');
const yt_dl = require('./controller/youtube-dl')
const dl = require('./controller/download');
const browser = require('./controller/windows.js/browser');
if (!fs.existsSync(global.dir+'/tmp/inst')) {
fs.writeFileSync(global.dir+'/tmp/inst',"out");
var win;
const createWindow = () =>{
win = new BrowserWindow({
width: 320,
height: 500,
@ -74,6 +78,7 @@ if (!fs.existsSync(global.dir+'/tmp/inst')) {
icon: __dirname + '/app.ico'
})
win.close();
//var z = new browser('http://www.crunchyroll.com/');
win2.loadURL(`file://${__dirname}/app/view/layout.html`)
win = win2;
});

View File

@ -0,0 +1,88 @@
/*
*/
@main-front-color : #f8f8f8;
@background-color : #111111;
@background-2ndcolor: #232323;
body {
margin: 0;
margin-top: 50px;
background: @background-color;
color:@main-front-color;
}
.btn-success {
color: @main-front-color;
background-color: @background-color;
border-color: @main-front-color;
transition: all .3s;
}
.btn-success:hover ,.btn-success:active,.btn-success:focus,.dropdown-toggle:focus,.dropdown-toggle:active,.btn-success:active, .btn-success.active, .open > .dropdown-toggle.btn-success {
color: @background-color !important;
background-color: @main-front-color !important;
border-color: @main-front-color !important;
transition: all .3s;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
text-decoration: none;
color: @main-front-color;
background-color: @background-color;
}
.dropdown-menu{
background-color: @background-color;
}
span.input-group-btn.open > ul > li> a{
background-image:none;
}
.progress{
background-image:none;
background-color: @background-color;
box-shadow: inset 0px 0px 3px 0px @main-front-color;
}
.progress-bar{
background-image:none;
background-color: @background-color;
box-shadow: inset 0px 0px 12px 0px @main-front-color;
transition: .3s all;
}
.media:first-child {
margin-top: 15px;
}
.media {
box-shadow: 0px 0px 6px 1px @main-front-color;
}
.sidebar-nav {
padding: 10px;
}
.nav.nav-list a {
padding: 5px 10px;
}
.nav-header {
font-weight: bold;
}
.scroll{
overflow-y: scroll;
height: ~"calc( 100vh - 96px)";
}
.left-playlist{
box-shadow: 0px 0px 6px 1px @main-front-color;
height: ~"calc(100vh - 20vw - 30px )";
}
.row-flex{
word-break: break-all;
width:100%;
display: flex;
.flex-btn{
width: 50px;
}
.cont{
width:100%;
}
}

15
src/tmp/c Normal file
View File

@ -0,0 +1,15 @@
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file! Do not edit.
.crunchyroll.com TRUE / FALSE 1534887951 __cfduid db1426254a0b86e7ca8b70551a18644361503351951
.crunchyroll.com TRUE / FALSE 1537220753 __qca P0-1835482882-1503351953593
.crunchyroll.com TRUE / FALSE 1566942248 _ga GA1.2.1843711990.1503351953
.crunchyroll.com TRUE / FALSE 1503956648 _gid GA1.2.1726060626.1503868189
.crunchyroll.com TRUE / FALSE 1504561873 c_d p%3D1
.crunchyroll.com TRUE / FALSE 1504561873 c_userid 64927993
.crunchyroll.com TRUE / FALSE 1504561873 c_userkey 2%3AZxOX%2BsILKGFm2Nmfc6%2FX12lxWjo%3D
.crunchyroll.com TRUE / FALSE 1518903952 c_visitor 95852853-d74d-4e9c-b5ad-182b74e6f44f
.crunchyroll.com TRUE / FALSE 1503960371 cf_clearance fb4b8c534496cdfec5683c51ec28dc2e4c70e5ce-1503351970-604800
.crunchyroll.com TRUE / FALSE 1537220753 sess_id jjdcwcg0amrsbt44eviz34disrmrqd2m
.crunchyroll.com TRUE / FALSE 1537220753 session_id 2074779edf6db7782876092c0d2f03db