modified: src/main.js
This commit is contained in:
parent
015c94d22a
commit
0b220ced8f
15
src/main.js
15
src/main.js
|
@ -1,5 +1,7 @@
|
|||
var cfg = require('../../cfg.json');
|
||||
var fs = require('fs');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var mysql = require('mysql');
|
||||
var bot = require('coffea')();
|
||||
const path = require('path');
|
||||
|
@ -52,7 +54,7 @@ var getUser = (u, n) => {
|
|||
|
||||
var dl = (url, dest, cb) => {
|
||||
var file = fs.createWriteStream(dest);
|
||||
var request = adapterFor(url).get(url, (response) => {
|
||||
var request = (url.match(/^https/)?https:http).get(url, (response) => {
|
||||
try {
|
||||
response.pipe(file);
|
||||
file.on('finish', () => {
|
||||
|
@ -70,14 +72,3 @@ var dl = (url, dest, cb) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
var adapterFor = (function() {
|
||||
var url = require('url'),
|
||||
adapters = {
|
||||
'http:': require('http'),
|
||||
'https:': require('https'),
|
||||
};
|
||||
return (inputUrl) => {
|
||||
return adapters[url.parse(inputUrl).protocol]
|
||||
}
|
||||
}());
|
Loading…
Reference in New Issue
Block a user