* parse yt as m4a
This commit is contained in:
		@@ -20,7 +20,7 @@ module.exports = (lib) => {
 | 
				
			|||||||
          var tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
 | 
					          var tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
 | 
				
			||||||
          tmp.forEach((entry,i,a) => {
 | 
					          tmp.forEach((entry,i,a) => {
 | 
				
			||||||
            if(!entry.match(/f0ck\.me/i) && !entry.match(/\.onion/i)) {
 | 
					            if(!entry.match(/f0ck\.me/i) && !entry.match(/\.onion/i)) {
 | 
				
			||||||
              getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), (e.message.match(/(!|-)mp3/i)?true:false), (cb) => {
 | 
					              getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), (e.message.match(/(!|-)audio/i)?true:false), (cb) => {
 | 
				
			||||||
                if(cb.success === true) {
 | 
					                if(cb.success === true) {
 | 
				
			||||||
                  fs.move(cb.file, cb.file + '.' + cb.info.ext, (err) => {
 | 
					                  fs.move(cb.file, cb.file + '.' + cb.info.ext, (err) => {
 | 
				
			||||||
                    if(!err) {
 | 
					                    if(!err) {
 | 
				
			||||||
@@ -64,7 +64,7 @@ module.exports = (lib) => {
 | 
				
			|||||||
    desc: 'muh'
 | 
					    desc: 'muh'
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  var getLink = (url, force, mp3, cb) => {
 | 
					  var getLink = (url, force, m4a, cb) => {
 | 
				
			||||||
    var yt = /https?:\/\/(www\.)?youtu(\.be\/|be\.com\/)((.+\/)?(watch(\?v=|.+&v=))?(v=)?)([\w_-]{11})(&.+)?/gi;
 | 
					    var yt = /https?:\/\/(www\.)?youtu(\.be\/|be\.com\/)((.+\/)?(watch(\?v=|.+&v=))?(v=)?)([\w_-]{11})(&.+)?/gi;
 | 
				
			||||||
    var sc = /https?:\/\/(www\.)?(soundcloud\.com|snd\.sc)(\/\S*)(\/\S*)/gi;
 | 
					    var sc = /https?:\/\/(www\.)?(soundcloud\.com|snd\.sc)(\/\S*)(\/\S*)/gi;
 | 
				
			||||||
    lib.checkRepost(url, (cbcr) => {
 | 
					    lib.checkRepost(url, (cbcr) => {
 | 
				
			||||||
@@ -78,15 +78,15 @@ module.exports = (lib) => {
 | 
				
			|||||||
              var title = inf.title;
 | 
					              var title = inf.title;
 | 
				
			||||||
              var iurl = inf.iurl;
 | 
					              var iurl = inf.iurl;
 | 
				
			||||||
              try {
 | 
					              try {
 | 
				
			||||||
                var dlformat = (mp3?'mp3':'webm');
 | 
					                var dlformat = (m4a?'m4a':'webm');
 | 
				
			||||||
                ytdl.downloadFromInfo(inf, { filter: (format) => { return format.container === dlformat; } })
 | 
					                ytdl.downloadFromInfo(inf, { filter: (format) => { return format.container === dlformat; } })
 | 
				
			||||||
                  .on('response', (res) => {
 | 
					                  .on('response', (res) => {
 | 
				
			||||||
                    if( ( res.headers['content-length'] <= lib.cfg.main.maxFileSize ) || force ) {
 | 
					                    if( ( res.headers['content-length'] <= lib.cfg.main.maxFileSize ) || force ) {
 | 
				
			||||||
                      info = {
 | 
					                      info = {
 | 
				
			||||||
                        type: 'youtube',
 | 
					                        type: 'youtube',
 | 
				
			||||||
                        title: title,
 | 
					                        title: title,
 | 
				
			||||||
                        mime: mp3?'audio/mpeg':'video/webm',
 | 
					                        mime: m4a?'audio/mp4':'video/webm',
 | 
				
			||||||
                        ext: mp3?'mp3':'webm',
 | 
					                        ext: m4a?'m4a':'webm',
 | 
				
			||||||
                        thumb: iurl
 | 
					                        thumb: iurl
 | 
				
			||||||
                      };
 | 
					                      };
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user