mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 18:56:21 +01:00
api/stream: move bsky override into isHlsResponse
This commit is contained in:
parent
bc597c817f
commit
bf4675a5e3
2 changed files with 6 additions and 6 deletions
|
@ -55,8 +55,11 @@ function transformMediaPlaylist(streamInfo, hlsPlaylist) {
|
||||||
|
|
||||||
const HLS_MIME_TYPES = ["application/vnd.apple.mpegurl", "audio/mpegurl", "application/x-mpegURL"];
|
const HLS_MIME_TYPES = ["application/vnd.apple.mpegurl", "audio/mpegurl", "application/x-mpegURL"];
|
||||||
|
|
||||||
export function isHlsResponse (req) {
|
export function isHlsResponse(req, streamInfo) {
|
||||||
return HLS_MIME_TYPES.includes(req.headers['content-type']);
|
return HLS_MIME_TYPES.includes(req.headers['content-type'])
|
||||||
|
// bluesky's cdn responds with wrong content-type for the hls playlist,
|
||||||
|
// so we enforce it here until they fix it
|
||||||
|
|| (streamInfo.service === 'bsky' && streamInfo.url.endsWith('.m3u8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleHlsPlaylist(streamInfo, req, res) {
|
export async function handleHlsPlaylist(streamInfo, req, res) {
|
||||||
|
|
|
@ -96,10 +96,7 @@ async function handleGenericStream(streamInfo, res) {
|
||||||
res.status(fileResponse.statusCode);
|
res.status(fileResponse.statusCode);
|
||||||
fileResponse.body.on('error', () => {});
|
fileResponse.body.on('error', () => {});
|
||||||
|
|
||||||
// bluesky's cdn responds with wrong content-type for the hls playlist,
|
const isHls = isHlsResponse(fileResponse, streamInfo);
|
||||||
// so we enforce it here until they fix it
|
|
||||||
const isHls = isHlsResponse(fileResponse)
|
|
||||||
|| (streamInfo.service === "bsky" && streamInfo.url.endsWith('.m3u8'));
|
|
||||||
|
|
||||||
for (const [ name, value ] of Object.entries(fileResponse.headers)) {
|
for (const [ name, value ] of Object.entries(fileResponse.headers)) {
|
||||||
if (!isHls || name.toLowerCase() !== 'content-length') {
|
if (!isHls || name.toLowerCase() !== 'content-length') {
|
||||||
|
|
Loading…
Reference in a new issue