mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 03:08:30 +00:00
fix: camelcase for abbreviations, makeInternalSegments
This commit is contained in:
parent
70b63495f2
commit
d40b1d1e48
@ -75,36 +75,36 @@ async function handleYoutubeStream(streamInfo, res) {
|
||||
}
|
||||
}
|
||||
|
||||
function transformHLSMediaPlaylist(streamInfo, hlsPlaylist) {
|
||||
function generateInternalStreamsOfSegments(segment) {
|
||||
function transformHlsMediaPlaylist(streamInfo, hlsPlaylist) {
|
||||
const makeInternalSegments = (segment) => {
|
||||
const fullUri = new URL(segment.uri, streamInfo.url).toString();
|
||||
segment.uri = createInternalStream(fullUri, streamInfo);
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
hlsPlaylist.segments =
|
||||
hlsPlaylist.segments.map(generateInternalStreamsOfSegments);
|
||||
hlsPlaylist.prefetchSegments =
|
||||
hlsPlaylist.prefetchSegments.map(generateInternalStreamsOfSegments);
|
||||
hlsPlaylist.segments = hlsPlaylist.segments.map(makeInternalSegments);
|
||||
hlsPlaylist.prefetchSegments = hlsPlaylist.prefetchSegments.map(makeInternalSegments);
|
||||
|
||||
return hlsPlaylist;
|
||||
}
|
||||
|
||||
async function handleHLSPlaylist(streamInfo, req, res) {
|
||||
async function handleHlsPlaylist(streamInfo, req, res) {
|
||||
let hlsPlaylist = await req.body.text();
|
||||
hlsPlaylist = HLS.parse(hlsPlaylist);
|
||||
|
||||
// NOTE no processing module is passing the master playlist
|
||||
assert(!hlsPlaylist.isMasterPlaylist);
|
||||
|
||||
hlsPlaylist = transformHLSMediaPlaylist(streamInfo, hlsPlaylist);
|
||||
hlsPlaylist = transformHlsMediaPlaylist(streamInfo, hlsPlaylist);
|
||||
hlsPlaylist = HLS.stringify(hlsPlaylist);
|
||||
|
||||
res.write(hlsPlaylist);
|
||||
res.end();
|
||||
}
|
||||
|
||||
const HLS_MIME_TYPES = ["application/vnd.apple.mpegurl", "audio/mpegurl", "application/x-mpegURL"];
|
||||
|
||||
export async function internalStream(streamInfo, res) {
|
||||
if (streamInfo.service === 'youtube') {
|
||||
return handleYoutubeStream(streamInfo, res);
|
||||
@ -129,8 +129,8 @@ export async function internalStream(streamInfo, res) {
|
||||
if (req.statusCode < 200 || req.statusCode > 299)
|
||||
return res.end();
|
||||
|
||||
if (["application/vnd.apple.mpegurl", "audio/mpegurl"].includes(req.headers['content-type'])) {
|
||||
await handleHLSPlaylist(streamInfo, req, res);
|
||||
if (HLS_MIME_TYPES.includes(req.headers['content-type'])) {
|
||||
await handleHlsPlaylist(streamInfo, req, res);
|
||||
} else {
|
||||
req.body.pipe(res);
|
||||
req.body.on('error', () => res.end());
|
||||
|
Loading…
Reference in New Issue
Block a user