-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Stitcher compatible with live streams (#122)
* Added support for multiple tags in EXTINF segment group * Refactored manual interstitials to support CUE * Error early when KV is not available on CF worker * Remove unused env variables for test * Simplified filter * Change content-type * Made sessionId optional * Do not expose outUrl * Added error log in app
- Loading branch information
Showing
30 changed files
with
394 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { parseEnv } from "shared/env"; | ||
|
||
export const env = parseEnv((z) => ({ | ||
// config.env | ||
REDIS_HOST: z.string().default("localhost"), | ||
REDIS_PORT: z.coerce.number().default(6379), | ||
S3_ENDPOINT: z.string(), | ||
S3_REGION: z.string(), | ||
S3_ACCESS_KEY: z.string(), | ||
S3_SECRET_KEY: z.string(), | ||
S3_BUCKET: z.string(), | ||
REDIS_HOST: z.string(), | ||
REDIS_PORT: z.coerce.number(), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { KVNamespace } from "@cloudflare/workers-types"; | ||
|
||
// Make sure wrangler.toml has a binding named "kv". | ||
const kv = process.env["kv"] as unknown as KVNamespace; | ||
|
||
if (!kv) { | ||
throw new ReferenceError( | ||
'No kv found for Cloudflare, make sure you have "kv"' + | ||
" set as binding in wrangler.toml.", | ||
); | ||
} | ||
|
||
export async function set(key: string, value: string, ttl: number) { | ||
await kv.put(key, value, { | ||
expirationTtl: ttl, | ||
}); | ||
} | ||
|
||
export async function get(key: string) { | ||
return await kv.get(key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { env } from "../../env"; | ||
|
||
interface KeyValue { | ||
set(key: string, value: string, ttl: number): Promise<void>; | ||
get(key: string): Promise<string | null>; | ||
} | ||
|
||
export let kv: KeyValue; | ||
|
||
// Map each KV adapter here to their corresponding import. | ||
if (env.KV === "cloudflare-kv") { | ||
kv = await import("./cloudflare-kv"); | ||
} else if (env.KV === "redis") { | ||
kv = await import("./redis"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createClient } from "redis"; | ||
import { env } from "../../env"; | ||
|
||
const REDIS_PREFIX = "stitcher"; | ||
|
||
const client = createClient({ | ||
socket: { | ||
host: env.REDIS_HOST, | ||
port: env.REDIS_PORT, | ||
}, | ||
}); | ||
|
||
await client.connect(); | ||
|
||
export async function set(key: string, value: string, ttl: number) { | ||
await client.set(`${REDIS_PREFIX}:${key}`, value, { | ||
EX: ttl, | ||
}); | ||
} | ||
|
||
export async function get(key: string) { | ||
return await client.get(`${REDIS_PREFIX}:${key}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.