feat: Add Xtream Codes API service for managing playlists, streams, and channels, including caching and proxy handling.

This commit is contained in:
Michael committed 2025-12-14 09:13:53 +01:00
1 parent 85deb540d2
commit 0c087e0b34
4 files changed
+275 -10

No files matched your search

+23 -6
View File
@@ -361,14 +361,31 @@
log('Stream type: ' + streamType);
const lowerUrl = streamUrl.toLowerCase();
// SPECIAL: /api/stream/ endpoint outputs MPEG-TS, use mpegts.js directly
// SPECIAL: /api/stream/ endpoint returns JSON with HLS playlist URL
if (streamUrl.includes('/api/stream/')) {
log('Detected /api/stream/ endpoint - using MPEG-TS player for transcoded stream');
log('Detected /api/stream/ - fetching HLS playlist URL...');
showLoading('Initializing stream (transcoding audio)...');
// For VOD, use isLive:false to enable seeking/duration
const isVodStream = (streamType === 'vod');
await playWithMpegTS(streamUrl, !isVodStream); // true for live, false for vod
return;
try {
// Fetch JSON response to get playlist URL
const response = await fetch(streamUrl);
const data = await response.json();
if (data.playlist) {
const playlistUrl = window.location.origin + data.playlist;
log('Got HLS playlist: ' + playlistUrl);
showLoading('Loading HLS stream...');
await playWithHLS(playlistUrl);
return;
} else {
showError('Invalid stream response');
return;
}
} catch (err) {
log('Error fetching playlist: ' + err);
showError('Failed to initialize stream');
return;
}
}
// Use type parameter if available, otherwise detect from URL