maxfilesize * 2 fuer Admins
This commit is contained in:
parent
e250cc7a48
commit
668de1ffbb
|
@ -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(/(!|-)audio/i)?true:false), (cb) => {
|
getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), userlevel, (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, m4a, cb) => {
|
var getLink = (url, force, userlevel, 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,21 +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 = (m4a?'audioonly':'webm');
|
dlformat = { filter: (format) => { return format.container === 'webm'; } };
|
||||||
var dlformat;
|
|
||||||
if(m4a)
|
|
||||||
dlformat = { format: '171' };
|
|
||||||
else
|
|
||||||
dlformat = { filter: (format) => { return format.container === 'webm'; } };
|
|
||||||
|
|
||||||
ytdl.downloadFromInfo(inf, dlformat)
|
ytdl.downloadFromInfo(inf, 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 || ( userlevel >= 70 && res.headers['content-length'] >= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||||
info = {
|
info = {
|
||||||
type: 'youtube',
|
type: 'youtube',
|
||||||
title: title,
|
title: title,
|
||||||
mime: (m4a?'audio/mpeg':'video/webm'),
|
mime: video/webm',
|
||||||
ext: (m4a?'mp3':'webm'),
|
ext: 'webm',
|
||||||
thumb: iurl
|
thumb: iurl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -147,7 +141,7 @@ module.exports = (lib) => {
|
||||||
lib.log('MimeType: '+type);
|
lib.log('MimeType: '+type);
|
||||||
var length = res.headers['content-length'];
|
var length = res.headers['content-length'];
|
||||||
if(lib.cfg.main.allowedMimes.hasOwnProperty(type)) {
|
if(lib.cfg.main.allowedMimes.hasOwnProperty(type)) {
|
||||||
if( ( data.length <= lib.cfg.main.maxFileSize ) || force ) {
|
if( ( data.length <= lib.cfg.main.maxFileSize ) || force || ( userlevel >= 70 && res.headers['content-length'] >= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||||
var s = new Readable
|
var s = new Readable
|
||||||
s.push(data);
|
s.push(data);
|
||||||
s.push(null);
|
s.push(null);
|
||||||
|
@ -181,7 +175,7 @@ module.exports = (lib) => {
|
||||||
.on('finish', () => {
|
.on('finish', () => {
|
||||||
var size = dat.bytesWritten;
|
var size = dat.bytesWritten;
|
||||||
dat.end();
|
dat.end();
|
||||||
if( ( size <= lib.cfg.main.maxFileSize ) || force ) {
|
if( ( size <= lib.cfg.main.maxFileSize ) || force || ( userlevel >= 70 && res.headers['content-length'] >= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||||
fs.stat('./b/' + tmpdest, (err, stat) => {
|
fs.stat('./b/' + tmpdest, (err, stat) => {
|
||||||
if(!err && stat.isFile() && stat.size > 300) {
|
if(!err && stat.isFile() && stat.size > 300) {
|
||||||
lib.log('Datei '+tmpdest+' existiert');
|
lib.log('Datei '+tmpdest+' existiert');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user