Added m3u8 stream support to media module. Added Elegant Angel. Added regex parameter to qu's number method. Various tags.
This commit is contained in:
27
src/media.js
27
src/media.js
@@ -10,7 +10,7 @@ const stream = require('stream');
|
||||
const nanoid = require('nanoid/non-secure');
|
||||
const mime = require('mime');
|
||||
// const fileType = require('file-type');
|
||||
const youtubeDl = require('youtube-dl');
|
||||
const ffmpeg = require('fluent-ffmpeg');
|
||||
const sharp = require('sharp');
|
||||
const blake2 = require('blake2');
|
||||
|
||||
@@ -418,22 +418,21 @@ async function fetchHttpSource(source, tempFileTarget, hashStream) {
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchStreamSource(source, tempFileTarget, hashStream) {
|
||||
const video = youtubeDl(source.stream);
|
||||
async function fetchStreamSource(source, tempFileTarget, tempFilePath, hashStream) {
|
||||
const meta = { mimetype: 'video/mp4' };
|
||||
|
||||
video.on('info', (info) => {
|
||||
console.log(info);
|
||||
logger.verbose(`Starting fetching stream from ${source.stream}`);
|
||||
});
|
||||
|
||||
video.on('end', (info) => {
|
||||
console.log(info);
|
||||
logger.verbose(`Finished fetching stream from ${source.stream}`);
|
||||
});
|
||||
const video = ffmpeg(source.stream)
|
||||
.format('mp4')
|
||||
.outputOptions(['-movflags frag_keyframe+empty_moov'])
|
||||
.on('start', cmd => logger.verbose(`Fetching stream from ${source.stream} with "${cmd}"`))
|
||||
.on('error', error => logger.error(`Failed to fetch stream from ${source.stream}: ${error.message}`))
|
||||
.pipe();
|
||||
|
||||
await pipeline(video, hashStream, tempFileTarget);
|
||||
|
||||
return { mimetype: null };
|
||||
logger.verbose(`Finished fetching stream from ${source.stream}`);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
async function fetchSource(source, baseMedia) {
|
||||
@@ -457,7 +456,7 @@ async function fetchSource(source, baseMedia) {
|
||||
});
|
||||
|
||||
const { mimetype } = source.stream
|
||||
? await fetchStreamSource(source, tempFileTarget, hashStream)
|
||||
? await fetchStreamSource(source, tempFileTarget, tempFilePath, hashStream)
|
||||
: await fetchHttpSource(source, tempFileTarget, hashStream);
|
||||
|
||||
hasher.end();
|
||||
|
||||
Reference in New Issue
Block a user