@@ -254,6 +254,10 @@ public function getDataForPlaylist(string $uuid, Request $request)
254254 if (! $ channelNo && ($ playlist ->auto_channel_increment || $ idChannelBy === PlaylistChannelId::Number)) {
255255 $ channelNo = ++$ channelNumber ;
256256 }
257+
258+ // Ensure we always have a unique identifier for the channel
259+ // Use database ID as fallback if channel number is not set
260+ $ channelKey = $ channelNo ?: $ channel ->id ;
257261 if ($ epgData ) {
258262 $ epgId = $ epgData ->epg_id ;
259263 $ epgIds [] = $ epgId ;
@@ -283,10 +287,10 @@ public function getDataForPlaylist(string $uuid, Request $request)
283287
284288 // Add the playlist channel info to the EPG channel map
285289 $ epgChannelMap [$ epgId ][$ epgData ->channel_id ][] = [
286- 'playlist_channel_id ' => $ channelNo ,
290+ 'playlist_channel_id ' => $ channelKey ,
287291 'display_name ' => $ channel ->title_custom ?? $ channel ->title ,
288292 'title ' => $ channel ->name_custom ?? $ channel ->name ,
289- 'channel_number ' => $ channel -> channel ,
293+ 'channel_number ' => $ channelNo ,
290294 'group ' => $ channel ->group ?? $ channel ->group_internal ,
291295 'logo ' => $ logo ?? '' ,
292296 ];
@@ -303,11 +307,11 @@ public function getDataForPlaylist(string $uuid, Request $request)
303307
304308 // Keep track of which channels need a dummy EPG program
305309 $ dummyEpgChannels [] = [
306- 'playlist_channel_id ' => $ channelNo ,
310+ 'playlist_channel_id ' => $ channelKey ,
307311 'display_name ' => $ channel ->title_custom ?? $ channel ->title ,
308312 'title ' => $ channel ->name_custom ?? $ channel ->name ,
309313 'icon ' => $ icon ,
310- 'channel_number ' => $ channel -> channel ,
314+ 'channel_number ' => $ channelNo ,
311315 'group ' => $ channel ->group ?? $ channel ->group_internal ,
312316 'include_category ' => $ playlist ->dummy_epg_category ,
313317 ];
@@ -364,8 +368,8 @@ public function getDataForPlaylist(string $uuid, Request $request)
364368 if ($ logoProxyEnabled ) {
365369 $ icon = LogoProxyController::generateProxyUrl ($ icon , internal: true );
366370 }
367- $ playlistChannelData [$ channelNo ] = [
368- 'id ' => $ channelNo ,
371+ $ playlistChannelData [$ channelKey ] = [
372+ 'id ' => $ channelKey ,
369373 'database_id ' => $ channel ->id , // Add the actual database ID for editing
370374 'url ' => $ url ,
371375 'format ' => $ channel ->is_vod
@@ -374,7 +378,7 @@ public function getDataForPlaylist(string $uuid, Request $request)
374378 'tvg_id ' => $ tvgId ,
375379 'display_name ' => $ channel ->title_custom ?? $ channel ->title ,
376380 'title ' => $ channel ->name_custom ?? $ channel ->name ,
377- 'channel_number ' => $ channel -> channel ,
381+ 'channel_number ' => $ channelNo ,
378382 'group ' => $ channel ->group ?? $ channel ->group_internal ,
379383 'icon ' => $ icon ,
380384 'has_epg ' => $ epgData !== null ,
0 commit comments