From cf6c5b43171129367aaaa44ae804085fdd3e88d0 Mon Sep 17 00:00:00 2001 From: 4gray Date: Thu, 26 Dec 2024 22:21:37 +0100 Subject: [PATCH] feat(xtream): add loadChannelEpg method to fetch EPG listings with decoding --- src/app/xtream-tauri/xtream.store.ts | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/app/xtream-tauri/xtream.store.ts b/src/app/xtream-tauri/xtream.store.ts index 483b2360a..ee2be1b5a 100644 --- a/src/app/xtream-tauri/xtream.store.ts +++ b/src/app/xtream-tauri/xtream.store.ts @@ -705,6 +705,7 @@ export const XtreamStore = signalStore( username: store.currentPlaylist().username, password: store.currentPlaylist().password, stream_id: store.selectedItem().xtream_id, + limit: 10, } ); @@ -733,6 +734,37 @@ export const XtreamStore = signalStore( return []; } }, + async loadChannelEpg(streamId: number) { + try { + const response = await dataService.fetchData( + `${store.currentPlaylist().serverUrl}/player_api.php`, + { + action: 'get_short_epg', + username: store.currentPlaylist().username, + password: store.currentPlaylist().password, + stream_id: streamId, + limit: 1, + } + ); + + if ( + response?.epg_listings && + Array.isArray(response.epg_listings) + ) { + return response.epg_listings.map((item) => ({ + ...item, + title: b64DecodeUnicode(item.title).trim(), + description: b64DecodeUnicode( + item.description + ).trim(), + })); + } + return []; + } catch (error) { + console.error('Error loading channel EPG:', error); + return []; + } + }, setHideExternalInfoDialog(hideExternalInfoDialog: boolean) { localStorage.setItem( 'hideExternalInfoDialog',