fix(livetv): fall back to legacy channels endpoint when cloud guide errors
This commit is contained in:
@@ -2513,20 +2513,29 @@ class PlexClient {
|
||||
final allChannels = <LiveTvChannel>[];
|
||||
for (final provider in _providerEpg) {
|
||||
final isCloudGuide = provider.identifier.startsWith('tv.plex.providers.epg');
|
||||
final primaryEndpoint = isCloudGuide ? '/lineups/plex/channels' : '/${provider.identifier}/lineups/dvr/channels';
|
||||
try {
|
||||
final response = await _getWithFailover(primaryEndpoint);
|
||||
final parsed = parseChannels(response);
|
||||
if (parsed.isEmpty && isCloudGuide) {
|
||||
// Fallback: the prefix matched but this server doesn't expose the
|
||||
// cloud endpoint. Retry with the legacy DVR endpoint.
|
||||
final fallback = await _getWithFailover('/${provider.identifier}/lineups/dvr/channels');
|
||||
allChannels.addAll(parseChannels(fallback));
|
||||
} else {
|
||||
allChannels.addAll(parsed);
|
||||
final legacyEndpoint = '/${provider.identifier}/lineups/dvr/channels';
|
||||
|
||||
if (isCloudGuide) {
|
||||
try {
|
||||
final response = await _getWithFailover('/lineups/plex/channels');
|
||||
final parsed = parseChannels(response);
|
||||
if (parsed.isNotEmpty) {
|
||||
allChannels.addAll(parsed);
|
||||
continue;
|
||||
}
|
||||
} catch (e) {
|
||||
appLogger.d(
|
||||
'Cloud channel endpoint /lineups/plex/channels unavailable, falling back to $legacyEndpoint',
|
||||
error: e,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await _getWithFailover(legacyEndpoint);
|
||||
allChannels.addAll(parseChannels(response));
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get EPG channels from ${provider.identifier} via $primaryEndpoint', error: e);
|
||||
appLogger.e('Failed to get EPG channels from ${provider.identifier} via $legacyEndpoint', error: e);
|
||||
}
|
||||
}
|
||||
return allChannels;
|
||||
|
||||
Reference in New Issue
Block a user