1.3.2.2
Offline watch
This commit is contained in:
parent
44042f5d5e
commit
acab4b1908
@ -3,7 +3,9 @@ $(function(){
|
|||||||
var out = $('#output');
|
var out = $('#output');
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const {dialog} = require('electron').remote;
|
const {
|
||||||
|
dialog
|
||||||
|
} = require('electron').remote;
|
||||||
|
|
||||||
var cache = {};
|
var cache = {};
|
||||||
var path = "";
|
var path = "";
|
||||||
@ -26,13 +28,28 @@ $(function(){
|
|||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
})[0];
|
})[0];
|
||||||
console.log(path)
|
console.log(path)
|
||||||
ipcRenderer.send('setPath', {path:path});
|
ipcRenderer.send('setPath', {
|
||||||
|
path: path
|
||||||
|
});
|
||||||
})
|
})
|
||||||
$('body').delegate('.format', 'click', function(e) {
|
$('body').delegate('.format', 'click', function(e) {
|
||||||
ipcRenderer.send('set-format', {format:e.currentTarget.dataset.format});
|
ipcRenderer.send('set-format', {
|
||||||
|
format: e.currentTarget.dataset.format
|
||||||
|
});
|
||||||
console.log(e.currentTarget.dataset.format);
|
console.log(e.currentTarget.dataset.format);
|
||||||
})
|
})
|
||||||
$('#start-download').click(function() {
|
$('#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></div>').prependTo('#output');
|
||||||
|
ipcRenderer.send('start-download', {
|
||||||
|
url: $('#url').val(),
|
||||||
|
id: video_id
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
|
||||||
var video_id = $('#url').val().split('v=')[1];
|
var video_id = $('#url').val().split('v=')[1];
|
||||||
var ampersandPosition = video_id.indexOf('&');
|
var ampersandPosition = video_id.indexOf('&');
|
||||||
if (ampersandPosition != -1) {
|
if (ampersandPosition != -1) {
|
||||||
@ -50,7 +67,11 @@ $(function(){
|
|||||||
var YT = JSON.parse(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');
|
$('<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;
|
cache[video_id] = YT.title;
|
||||||
ipcRenderer.send('start-download-pl', {url:$('#url').val(),id:video_id,folder:YT.author_name+'-'+YT.title});
|
ipcRenderer.send('start-download-pl', {
|
||||||
|
url: $('#url').val(),
|
||||||
|
id: video_id,
|
||||||
|
folder: YT.author_name + '-' + YT.title
|
||||||
|
});
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
request
|
request
|
||||||
@ -58,11 +79,15 @@ $(function(){
|
|||||||
var YT = JSON.parse(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');
|
$('<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;
|
cache[video_id] = YT.title;
|
||||||
ipcRenderer.send('start-download', {url:$('#url').val(),id:video_id});
|
ipcRenderer.send('start-download', {
|
||||||
|
url: $('#url').val(),
|
||||||
|
id: video_id
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log(playlist_id + ' id:' + video_id)
|
console.log(playlist_id + ' id:' + video_id)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
34
src/controller/crunchyroll.js
Normal file
34
src/controller/crunchyroll.js
Normal 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;
|
@ -5,6 +5,8 @@ const {
|
|||||||
session
|
session
|
||||||
} = require('electron');
|
} = require('electron');
|
||||||
|
|
||||||
|
const crunch = require('./../crunchyroll')
|
||||||
|
|
||||||
class browser {
|
class browser {
|
||||||
constructor(url){
|
constructor(url){
|
||||||
console.log("TEST")
|
console.log("TEST")
|
||||||
@ -17,7 +19,8 @@ class browser {
|
|||||||
})
|
})
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
session.defaultSession.cookies.get({url:'http://crunchyroll.com'}, (error, cookies) => {
|
session.defaultSession.cookies.get({url:'http://crunchyroll.com'}, (error, cookies) => {
|
||||||
console.log(error, cookies)
|
//console.log(error, cookies)
|
||||||
|
crunch.session_save(cookies);
|
||||||
})
|
})
|
||||||
},3000)
|
},3000)
|
||||||
var window = this.window
|
var window = this.window
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
const ipcMain = require('electron').ipcMain;
|
const ipcMain = require('electron').ipcMain;
|
||||||
|
const dl_routine = require('./youtube-dl.routine')
|
||||||
console.log(global.dir);
|
console.log(global.dir);
|
||||||
|
|
||||||
var orig_path = "";
|
var orig_path = "";
|
||||||
@ -54,16 +55,9 @@ var yt_dl = class{
|
|||||||
var log = [];
|
var log = [];
|
||||||
var me = this;
|
var me = this;
|
||||||
var ls;
|
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 == ''){
|
if(path == ''){
|
||||||
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url]);
|
//ls = spawn(global.dir+'/lib/youtube-dl', ['-x','--audio-format','mp3','-i',this.url]);
|
||||||
}else{
|
}else{
|
||||||
|
31
src/controller/youtube-dl.routine.js
Normal file
31
src/controller/youtube-dl.routine.js
Normal 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 = ['-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];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user