This commit is contained in:
Theenoro 2018-03-21 23:43:29 +01:00
parent c569c0beca
commit 7f6f74f50b
5 changed files with 47 additions and 18 deletions

2
.gitignore vendored
View File

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

View File

@ -96,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>

View File

@ -1,16 +1,21 @@
const request = require('request');
// https://vivo.sx/46b5f0d914
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])
});
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+/=",

View File

@ -24,12 +24,20 @@ 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, arg.title);
download.addListen(event)
download.download();
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) => {
format = arg.format;
@ -79,6 +87,7 @@ var yt_dl = class {
var ls;
var m = dl_routine(path, this.url, format, this.title);
console.log('CMD: '+m[0]+' '+ m[1]);
ls = spawn(m[0], m[1]);
@ -151,10 +160,13 @@ var yt_dl = class {
});
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('&');
@ -187,4 +199,10 @@ var yt_dl = class {
}
}
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

@ -5,8 +5,11 @@ module.exports = (path, url, format, title = "%(title)s") => {
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+'.%(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+'.%(ext)s'];