|
3 | 3 | namespace App\Services; |
4 | 4 |
|
5 | 5 | use App\Facades\ProxyFacade; |
| 6 | +use App\Facades\PlaylistFacade; |
6 | 7 | use App\Models\Channel; |
7 | 8 | use App\Models\CustomPlaylist; |
8 | 9 | use App\Models\Episode; |
@@ -670,19 +671,15 @@ public function getChannelUrl($playlist, $channel, ?Request $request = null, ?St |
670 | 671 | // See if channel has any failovers |
671 | 672 | // Return bool if using resolver, else array of failover URLs (legacy mode) |
672 | 673 | $failovers = $this->usingResolver() |
673 | | - ? $channel->failoverChannels()->count() > 0 |
674 | | - : $channel->failoverChannels() |
675 | | - ->select(['channels.id', 'channels.url', 'channels.url_custom', 'channels.playlist_id', 'channels.custom_playlist_id'])->get() |
676 | | - ->map(function ($ch) { |
677 | | - $playlist = $ch->getEffectivePlaylist(); |
678 | | - if (! $playlist) { |
679 | | - return null; |
680 | | - } |
681 | | - return PlaylistUrlService::getChannelUrl($ch, $playlist); |
682 | | - }) |
683 | | - ->filter() |
684 | | - ->values() |
685 | | - ->toArray(); |
| 674 | + ? $channel->failoverChannels()->count() > 0 |
| 675 | + : $channel->failoverChannels() |
| 676 | + ->select(['channels.id', 'channels.url', 'channels.url_custom', 'channels.playlist_id', 'channels.custom_playlist_id'])->get() |
| 677 | + ->map(function ($ch) use ($playlist) { |
| 678 | + return PlaylistUrlService::getChannelUrl($ch, $playlist); |
| 679 | + }) |
| 680 | + ->filter() |
| 681 | + ->values() |
| 682 | + ->toArray(); |
686 | 683 |
|
687 | 684 | // Use appropriate endpoint based on whether transcoding profile is provided |
688 | 685 | if ($profile) { |
@@ -1429,6 +1426,8 @@ public function resolveFailoverUrl(int $channelId, string $playlistUuid, string |
1429 | 1426 | // Get the original channel to access its failover relationships |
1430 | 1427 | $channel = Channel::findOrFail($channelId); |
1431 | 1428 | $nextUrl = null; |
| 1429 | + // Resolve the original stream context by UUID (Playlist / MergedPlaylist / CustomPlaylist / PlaylistAlias) |
| 1430 | + $contextPlaylist = !empty($playlistUuid) ? PlaylistFacade::resolvePlaylistByUuid($playlistUuid) : null; |
1432 | 1431 |
|
1433 | 1432 | // Get all failover channels with their relationships |
1434 | 1433 | $failoverChannels = $channel->failoverChannels() |
@@ -1459,7 +1458,7 @@ public function resolveFailoverUrl(int $channelId, string $playlistUuid, string |
1459 | 1458 | } |
1460 | 1459 |
|
1461 | 1460 | // Get the url |
1462 | | - $url = PlaylistUrlService::getChannelUrl($failoverChannel, $failoverPlaylist); |
| 1461 | + $url = PlaylistUrlService::getChannelUrl($failoverChannel, $contextPlaylist ?? $failoverPlaylist); |
1463 | 1462 |
|
1464 | 1463 | // Check if the url is the current URL (skip it) |
1465 | 1464 | if ($url === $currentUrl) { |
|
0 commit comments