diff --git a/.gitignore b/.gitignore index 56a287e..78f6f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,5 @@ out *.mp3 *.part *.ytdl + +*.webm diff --git a/src/app/view/layout.html b/src/app/view/layout.html index e4009ed..470143c 100644 --- a/src/app/view/layout.html +++ b/src/app/view/layout.html @@ -96,6 +96,7 @@
diff --git a/src/controller/crawler/vivo.sx.js b/src/controller/crawler/vivo.sx.js index 16b4526..7d8709d 100644 --- a/src/controller/crawler/vivo.sx.js +++ b/src/controller/crawler/vivo.sx.js @@ -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+/=", diff --git a/src/controller/youtube-dl.js b/src/controller/youtube-dl.js index 729d4b5..6ea87f9 100644 --- a/src/controller/youtube-dl.js +++ b/src/controller/youtube-dl.js @@ -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; diff --git a/src/controller/youtube-dl.routine.js b/src/controller/youtube-dl.routine.js index 1883413..43c7f09 100644 --- a/src/controller/youtube-dl.routine.js +++ b/src/controller/youtube-dl.routine.js @@ -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'];