diff --git a/index.js b/index.js index 9f3e61c..f61a70d 100644 --- a/index.js +++ b/index.js @@ -44,11 +44,14 @@ app.get('/stream/:channelId', async (req, res) => { }); const data = response.data; - if (!data || !data.content || !data.content.livePlaybackJson) { - return res.status(404).send('Stream not found or offline'); + const content = data && data.content; + const playbackJsonString = content && (content.livePlaybackJson || content.previewPlaybackJson); + + if (!playbackJsonString) { + return res.status(404).send('Stream not found, offline, or region blocked'); } - const livePlayback = JSON.parse(data.content.livePlaybackJson); + const livePlayback = JSON.parse(playbackJsonString); const media = livePlayback.media || []; // Find HLS or LLHLS stream