Skip to content

Commit

Permalink
fix: Support for short master url in stitcher
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Nov 14, 2024
1 parent 1b665b9 commit a07771e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/stitcher/src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export function parseFilterQuery(query: Record<string, string>) {
return filter;
}

export function buildFilterQuery(filter: Filter) {
export function filterQuery(filter?: Filter) {
return {
"filter.resolution": filter.resolution,
"filter.audioLanguage": filter.audioLanguage,
"filter.resolution": filter?.resolution,
"filter.audioLanguage": filter?.audioLanguage,
};
}
6 changes: 3 additions & 3 deletions packages/stitcher/src/lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export function resolveUri(uri: string) {

function buildUrl(
url: string,
query?: Record<string, string | number | undefined | null>,
query: Record<string, string | number | undefined | null> = {},
) {
const queryString = Object.entries(query ?? {})
const queryString = Object.entries(query)
.map(([key, value]) => {
if (value === undefined || value === null) {
return null;
Expand Down Expand Up @@ -70,7 +70,7 @@ export function buildProxyUrl(
options: {
url?: string;
session?: Session;
params?: Record<string, string>;
params?: Record<string, string | undefined>;
} = {},
) {
const { url, session, params } = options;
Expand Down
8 changes: 6 additions & 2 deletions packages/stitcher/src/routes/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Elysia, t } from "elysia";
import { assert } from "shared/assert";
import { parseFilterQuery } from "../filters";
import { filterQuery, parseFilterQuery } from "../filters";
import { decrypt } from "../lib/crypto";
import { buildProxyUrl } from "../lib/url";
import {
Expand All @@ -20,7 +20,11 @@ export const session = new Elysia()
async ({ body }) => {
const session = await createSession(body);

const url = buildProxyUrl(`${session.id}/master.m3u8`);
const url = buildProxyUrl(`${session.id}/master.m3u8`, {
params: {
...filterQuery(body.filter),
},
});

return { url };
},
Expand Down

0 comments on commit a07771e

Please sign in to comment.