mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
Update hardcoded Cloudflare Stream UID to a constant and remove dynamic HLS URL updates
This commit is contained in:
@@ -22,8 +22,9 @@ export const Route = createFileRoute("/$username")({
|
|||||||
component: StreamPage,
|
component: StreamPage,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Default Cloudflare Stream HLS URL (will be overridden by API)
|
// Cloudflare Live Input UID (constant - automatically shows current live stream)
|
||||||
const DEFAULT_HLS_URL = "https://customer-xctsztqzu046isdc.cloudflarestream.com/cd56ef73791c628c252cd290ee710275/manifest/video.m3u8"
|
const LIVE_INPUT_UID = "bb7858eafc85de6c92963f3817477b5d"
|
||||||
|
const HLS_URL = `https://customer-xctsztqzu046isdc.cloudflarestream.com/${LIVE_INPUT_UID}/manifest/video.m3u8`
|
||||||
const READY_PULSE_MS = 1200
|
const READY_PULSE_MS = 1200
|
||||||
|
|
||||||
// Hardcoded user for nikiv (hls_url will be updated from API)
|
// Hardcoded user for nikiv (hls_url will be updated from API)
|
||||||
@@ -58,7 +59,6 @@ function StreamPage() {
|
|||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
const [playerReady, setPlayerReady] = useState(false)
|
const [playerReady, setPlayerReady] = useState(false)
|
||||||
const [hlsLive, setHlsLive] = useState<boolean | null>(null)
|
const [hlsLive, setHlsLive] = useState<boolean | null>(null)
|
||||||
const [hlsUrl, setHlsUrl] = useState<string>(DEFAULT_HLS_URL)
|
|
||||||
const [isConnecting, setIsConnecting] = useState(false)
|
const [isConnecting, setIsConnecting] = useState(false)
|
||||||
const [nowPlaying, setNowPlaying] = useState<SpotifyNowPlayingResponse | null>(
|
const [nowPlaying, setNowPlaying] = useState<SpotifyNowPlayingResponse | null>(
|
||||||
null,
|
null,
|
||||||
@@ -78,9 +78,9 @@ function StreamPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isActive = true
|
let isActive = true
|
||||||
|
|
||||||
// Special handling for nikiv - hardcoded stream with dynamic HLS URL
|
// Special handling for nikiv - hardcoded stream with constant Live Input URL
|
||||||
if (username === "nikiv") {
|
if (username === "nikiv") {
|
||||||
setData(makeNikivData(hlsUrl))
|
setData(makeNikivData(HLS_URL))
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
return () => {
|
return () => {
|
||||||
isActive = false
|
isActive = false
|
||||||
@@ -197,12 +197,6 @@ function StreamPage() {
|
|||||||
|
|
||||||
const apiData = await res.json()
|
const apiData = await res.json()
|
||||||
|
|
||||||
// Update HLS URL if returned from API
|
|
||||||
if (apiData.hlsUrl && apiData.hlsUrl !== hlsUrl) {
|
|
||||||
setHlsUrl(apiData.hlsUrl)
|
|
||||||
setData(makeNikivData(apiData.hlsUrl))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apiData.isLive) {
|
if (apiData.isLive) {
|
||||||
// Stream is live - set connecting state if first time
|
// Stream is live - set connecting state if first time
|
||||||
if (!hasConnectedOnce.current) {
|
if (!hasConnectedOnce.current) {
|
||||||
@@ -232,7 +226,7 @@ function StreamPage() {
|
|||||||
isActive = false
|
isActive = false
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
}
|
}
|
||||||
}, [username, hlsUrl])
|
}, [username])
|
||||||
|
|
||||||
// For non-nikiv users, use direct HLS check
|
// For non-nikiv users, use direct HLS check
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createFileRoute, getServerContext } from "@tanstack/react-router"
|
import { createFileRoute } from "@tanstack/react-router"
|
||||||
|
|
||||||
const json = (data: unknown, status = 200) =>
|
const json = (data: unknown, status = 200) =>
|
||||||
new Response(JSON.stringify(data), {
|
new Response(JSON.stringify(data), {
|
||||||
@@ -6,13 +6,12 @@ const json = (data: unknown, status = 200) =>
|
|||||||
headers: { "content-type": "application/json" },
|
headers: { "content-type": "application/json" },
|
||||||
})
|
})
|
||||||
|
|
||||||
// Default video ID (fallback)
|
// Cloudflare Live Input UID (constant - automatically shows current live stream)
|
||||||
const DEFAULT_VIDEO_ID = "cd56ef73791c628c252cd290ee710275"
|
const LIVE_INPUT_UID = "bb7858eafc85de6c92963f3817477b5d"
|
||||||
|
const HLS_URL = `https://customer-xctsztqzu046isdc.cloudflarestream.com/${LIVE_INPUT_UID}/manifest/video.m3u8`
|
||||||
|
|
||||||
function getHlsUrl(): string {
|
function getHlsUrl(): string {
|
||||||
const ctx = (getServerContext as () => { cloudflare?: { env?: Record<string, string> } } | null)()
|
return HLS_URL
|
||||||
const videoId = ctx?.cloudflare?.env?.CLOUDFLARE_STREAM_NIKIV_VIDEO_ID || DEFAULT_VIDEO_ID
|
|
||||||
return `https://customer-xctsztqzu046isdc.cloudflarestream.com/${videoId}/manifest/video.m3u8`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHlsPlaylistLive(manifest: string): boolean {
|
function isHlsPlaylistLive(manifest: string): boolean {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
"vars": {
|
"vars": {
|
||||||
"APP_BASE_URL": "https://linsa.io",
|
"APP_BASE_URL": "https://linsa.io",
|
||||||
"CLOUDFLARE_STREAM_NIKIV_VIDEO_ID": "cd56ef73791c628c252cd290ee710275"
|
"CLOUDFLARE_LIVE_INPUT_UID": "bb7858eafc85de6c92963f3817477b5d"
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Note: Use secrets to store sensitive data.
|
* Note: Use secrets to store sensitive data.
|
||||||
|
|||||||
Reference in New Issue
Block a user