mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-11 22:40:32 +01:00
Fix HLS live check to handle fetch errors and improve polling logic
This commit is contained in:
@@ -274,10 +274,9 @@ function StreamPage() {
|
||||
}
|
||||
}
|
||||
|
||||
setStreamReady(false)
|
||||
setHlsLive(null)
|
||||
const checkHlsLive = () => {
|
||||
console.log("[HLS Check] Fetching manifest:", activePlayback.url)
|
||||
fetch(activePlayback.url)
|
||||
fetch(activePlayback.url, { cache: "no-store" })
|
||||
.then(async (res) => {
|
||||
if (isActive) {
|
||||
console.log("[HLS Check] Response status:", res.status, res.ok)
|
||||
@@ -301,9 +300,19 @@ function StreamPage() {
|
||||
setHlsLive(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Initial check
|
||||
setStreamReady(false)
|
||||
setHlsLive(null)
|
||||
checkHlsLive()
|
||||
|
||||
// Poll every 5 seconds to detect when stream goes live
|
||||
const interval = setInterval(checkHlsLive, 5000)
|
||||
|
||||
return () => {
|
||||
isActive = false
|
||||
clearInterval(interval)
|
||||
}
|
||||
}, [
|
||||
activePlayback?.type,
|
||||
@@ -341,11 +350,13 @@ function StreamPage() {
|
||||
}
|
||||
}, [activePlayback?.type, stream?.hls_url])
|
||||
|
||||
// For nikiv, use streamLive from the polled API status
|
||||
// For nikiv, primarily use HLS live check from Cloudflare
|
||||
// Fall back to streamLive status if HLS check hasn't completed
|
||||
// For other users, use stream?.is_live from the database
|
||||
const isLiveStatus = username === "nikiv" ? streamLive : Boolean(stream?.is_live)
|
||||
const isActuallyLive =
|
||||
isLiveStatus && (activePlayback?.type !== "hls" || hlsLive !== false)
|
||||
const isLiveStatus = username === "nikiv"
|
||||
? (hlsLive === true || (hlsLive === null && streamLive))
|
||||
: Boolean(stream?.is_live)
|
||||
const isActuallyLive = isLiveStatus
|
||||
const shouldFetchSpotify = username === "nikiv" && !isActuallyLive
|
||||
|
||||
// Debug logging for stream status
|
||||
|
||||
Reference in New Issue
Block a user