Adding media streaming experiments.

This commit is contained in:
ThePendulum 2020-04-20 23:52:37 +02:00
parent 4b26f8f476
commit 2cfbd21560
1 changed files with 7 additions and 3 deletions

View File

@ -4,6 +4,7 @@ const config = require('config');
const Promise = require('bluebird'); const Promise = require('bluebird');
const fs = require('fs').promises; const fs = require('fs').promises;
const path = require('path'); const path = require('path');
const bhttp = require('bhttp');
const nanoid = require('nanoid/non-secure'); const nanoid = require('nanoid/non-secure');
const mime = require('mime'); const mime = require('mime');
// const fileType = require('file-type'); // const fileType = require('file-type');
@ -371,9 +372,12 @@ async function fetchSource(source) {
const extension = mime.getExtension(mimetype); const extension = mime.getExtension(mimetype);
const type = mimetype?.split('/')[0] || 'image'; const type = mimetype?.split('/')[0] || 'image';
const res = await http.get(source.src, { const res = await bhttp.get(source.src, {
...(source.referer && { referer: source.referer }), headers: {
...(source.host && { host: source.host }), ...(source.referer && { referer: source.referer }),
...(source.host && { host: source.host }),
},
stream: true,
}); });
if (!res.ok) { if (!res.ok) {