fix(tv): use channel key for tuning and EPG matching

This commit is contained in:
edde746
2026-02-13 17:23:02 +01:00
parent f4d940af10
commit fd53acbb92
5 changed files with 11 additions and 19 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ class LiveTvChannel {
title: json['title'] as String? ?? json['callSign'] as String?,
thumb: json['thumb'] as String?,
art: json['art'] as String?,
number: json['number'] as String? ?? json['channelNumber'] as String?,
number: json['number'] as String? ?? json['channelNumber'] as String? ?? json['channelVcn']?.toString(),
hd: json['hd'] == true || json['hd'] == 1,
lineup: json['lineup'] as String?,
slug: json['slug'] as String?,
+1 -5
View File
@@ -118,12 +118,8 @@ class _LiveTvScreenState extends State<LiveTvScreen> with SingleTickerProviderSt
final channels = await client.getEpgChannels(lineup: serverInfo.lineup);
appLogger.d('Channels from DVR ${serverInfo.dvrKey}: ${channels.length} channels');
if (channels.isNotEmpty) {
final sample = channels.first;
appLogger.d('Sample channel: key=${sample.key} identifier=${sample.identifier} number=${sample.number} slug=${sample.slug}');
}
for (final channel in channels) {
final dedupKey = '${serverInfo.serverId}:${channel.identifier ?? channel.key}';
final dedupKey = '${serverInfo.serverId}:${channel.key}';
if (seenChannels.add(dedupKey)) {
allChannels.add(channel);
}
+1 -2
View File
@@ -258,8 +258,7 @@ class GuideTabState extends State<GuideTab> {
}
List<LiveTvProgram> _getProgramsForChannel(LiveTvChannel channel) {
final channelId = channel.identifier ?? channel.key;
return _programs.where((p) => p.channelIdentifier == channelId).toList()
return _programs.where((p) => p.channelIdentifier == channel.key).toList()
..sort((a, b) => (a.beginsAt ?? 0).compareTo(b.beginsAt ?? 0));
}
+4 -6
View File
@@ -867,10 +867,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
throw Exception('No channel to tune');
}
final channel = channels[channelIndex];
final channelId = channel.identifier ?? channel.key;
appLogger.d('Tune: dvrKey=${widget.liveDvrKey} channelId=$channelId (identifier=${channel.identifier}, key=${channel.key})');
appLogger.d('Tune: dvrKey=${widget.liveDvrKey} channelKey=${channel.key}');
final client = widget.liveClient!;
final result = await client.tuneChannel(widget.liveDvrKey!, channelId);
final result = await client.tuneChannel(widget.liveDvrKey!, channel.key);
if (result == null) throw Exception('Failed to tune channel');
streamUrl = '${client.config.baseUrl}${result.streamPath}'
@@ -1722,8 +1721,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
await _sendLiveTimeline('stopped');
final channel = channels[newIndex];
final channelId = channel.identifier ?? channel.key;
appLogger.d('Switching to channel: ${channel.displayName} ($channelId) (identifier=${channel.identifier}, key=${channel.key})');
appLogger.d('Switching to channel: ${channel.displayName} (${channel.key})');
setState(() => _hasFirstFrame.value = false);
@@ -1739,7 +1737,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
final client = multiServer.getClientForServer(serverInfo.serverId);
if (client == null) return;
final result = await client.tuneChannel(serverInfo.dvrKey, channelId);
final result = await client.tuneChannel(serverInfo.dvrKey, channel.key);
if (result == null || !mounted) return;
final streamUrl = '${client.config.baseUrl}${result.streamPath}'.withPlexToken(client.config.token);
+4 -5
View File
@@ -21,14 +21,13 @@ Future<void> navigateToLiveTv(
required LiveTvChannel channel,
List<LiveTvChannel>? channels,
}) async {
final channelId = channel.identifier ?? channel.key;
final navigator = Navigator.of(context);
appLogger.d('Navigating to live channel: ${channel.displayName} ($channelId)');
appLogger.d('Navigating to live channel: ${channel.displayName} (${channel.key})');
final placeholder = PlexMetadata(
ratingKey: channelId,
key: channelId,
ratingKey: channel.key,
key: channel.key,
type: 'clip',
title: channel.displayName,
);
@@ -42,7 +41,7 @@ Future<void> navigateToLiveTv(
liveStreamUrl: null,
liveChannels: channels,
liveCurrentChannelIndex: channels?.indexWhere(
(ch) => (ch.identifier ?? ch.key) == channelId,
(ch) => ch.key == channel.key,
),
liveDvrKey: dvrKey,
liveClient: client,