parse yt as mp3
This commit is contained in:
parent
ad9db1df30
commit
2d682d4fb8
@ -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), (cb) => {
|
getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), (e.message.match(/(!|-)mp3/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, cb) => {
|
var getLink = (url, force, mp3, 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,14 +78,15 @@ module.exports = (lib) => {
|
|||||||
var title = inf.title;
|
var title = inf.title;
|
||||||
var iurl = inf.iurl;
|
var iurl = inf.iurl;
|
||||||
try {
|
try {
|
||||||
ytdl.downloadFromInfo(inf, { filter: (format) => { return format.container === 'webm'; } })
|
var dlformat = (mp3?'mp3':'webm');
|
||||||
|
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: 'video/webm',
|
mime: mp3?'audio/mpeg':'video/webm',
|
||||||
ext: 'webm',
|
ext: mp3?'mp3':'webm',
|
||||||
thumb: iurl
|
thumb: iurl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user