feat: streamed sports api compatability
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const m3uParser = require('iptv-playlist-parser');
|
||||
const ChannelService = require('./ChannelService');
|
||||
const ChannelStorage = require('./ChannelStorage');
|
||||
const StreamedSuSession = require('./session/StreamedSuSession');
|
||||
|
||||
class PlaylistService {
|
||||
|
||||
@@ -12,6 +13,18 @@ class PlaylistService {
|
||||
if(playlist.startsWith("http")) {
|
||||
const response = await fetch(playlist);
|
||||
content = await response.text();
|
||||
|
||||
//check for streamedSu here and add channel for every source
|
||||
if(playlist.includes('streamed.su')) {
|
||||
console.log('Fetching StreamedSu API channels');
|
||||
const channels = await StreamedSuSession.fetchApiChannels(playlist, mode, headersJson, playlistName);
|
||||
channels.forEach(channel => {
|
||||
ChannelService.addChannel(channel, false);
|
||||
});
|
||||
|
||||
ChannelStorage.save(ChannelService.getChannels());
|
||||
return channels;
|
||||
}
|
||||
} else {
|
||||
content = playlist;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,44 @@ class StreamedSuSession extends SessionHandler {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
static async fetchApiChannels(apiUrl, mode, headersJson, playlistName) {
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error(response);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
let channels = [];
|
||||
data.forEach(stream => {
|
||||
const { title, category, poster, sources } = stream;
|
||||
|
||||
for(const source of sources) {
|
||||
const channelUrl = `https://rr.vipstreams.in/${source.source}/js/${source.id}/1/playlist.m3u8`;
|
||||
const channelAvatar = `https://streamed.su${poster ?? '/api/images/poster/fallback.webp'}`;
|
||||
|
||||
channels.push({
|
||||
name: title,
|
||||
url: channelUrl,
|
||||
avatar: channelAvatar,
|
||||
mode: mode,
|
||||
headersJson: headersJson,
|
||||
group: category,
|
||||
playlist: apiUrl,
|
||||
playlistName: playlistName
|
||||
});
|
||||
}
|
||||
});
|
||||
return channels;
|
||||
} catch (error) {
|
||||
console.error('Fetch StreamedSu API failed:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async createSession() {
|
||||
|
||||
console.log('Creating session:', this.channel.url);
|
||||
|
||||
@@ -430,7 +430,7 @@ function ChannelModal({ onClose, channel }: ChannelModalProps) {
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{headers.map((header, index) => (
|
||||
{headers && headers.map((header, index) => (
|
||||
<div key={index} className="flex items-center space-x-2">
|
||||
<CustomHeaderInput
|
||||
header={header}
|
||||
|
||||
Reference in New Issue
Block a user