tokens refresh on media start
This commit is contained in:
@@ -61,7 +61,7 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
public string Description => "Swiss Radio and Television video-on-demand content";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DataVersion => "1.0";
|
||||
public string DataVersion => "1.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string HomePageUrl => "https://www.srf.ch/play";
|
||||
@@ -433,36 +433,34 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
// Generate deterministic GUID from URN
|
||||
var itemId = UrnToGuid(urn);
|
||||
|
||||
// Get stream URL and authenticate it
|
||||
// Get stream URL (unauthenticated - token will be added at playback time by SRFMediaProvider)
|
||||
var streamUrl = _streamResolver.GetStreamUrl(chapter, config.QualityPreference);
|
||||
|
||||
// For scheduled livestreams that haven't started, streamUrl might be null
|
||||
var isUpcomingLivestream = chapter.Type == "SCHEDULED_LIVESTREAM" && string.IsNullOrEmpty(streamUrl);
|
||||
|
||||
if (!string.IsNullOrEmpty(streamUrl))
|
||||
// Skip scheduled livestreams that haven't started yet (no stream URL available)
|
||||
if (chapter.Type == "SCHEDULED_LIVESTREAM" && string.IsNullOrEmpty(streamUrl))
|
||||
{
|
||||
// Authenticate the stream URL (required for all SRF streams, especially livestreams)
|
||||
streamUrl = await _streamResolver.GetAuthenticatedStreamUrlAsync(streamUrl, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (isUpcomingLivestream)
|
||||
{
|
||||
// Use a placeholder for upcoming events
|
||||
streamUrl = "http://placeholder.local/upcoming.m3u8";
|
||||
_logger.LogInformation(
|
||||
"URN {Urn}: Upcoming livestream '{Title}' - stream will be available at {ValidFrom}",
|
||||
_logger.LogDebug(
|
||||
"URN {Urn}: Skipping upcoming livestream '{Title}' - stream not yet available (starts at {ValidFrom})",
|
||||
urn,
|
||||
chapter.Title,
|
||||
chapter.ValidFrom);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build overview with event time for upcoming livestreams
|
||||
var overview = chapter.Description ?? chapter.Lead;
|
||||
if (isUpcomingLivestream && chapter.ValidFrom != null)
|
||||
// Skip items without a valid stream URL
|
||||
if (string.IsNullOrEmpty(streamUrl))
|
||||
{
|
||||
var eventStart = chapter.ValidFrom.Value.ToString("dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture);
|
||||
overview = $"[Upcoming Event - Starts at {eventStart}]\n\n{overview}";
|
||||
_logger.LogWarning(
|
||||
"URN {Urn}: Skipping '{Title}' - no valid stream URL available",
|
||||
urn,
|
||||
chapter.Title);
|
||||
noStreamCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build overview
|
||||
var overview = chapter.Description ?? chapter.Lead;
|
||||
|
||||
// Get image URL - prefer chapter image, fall back to show image if available
|
||||
var imageUrl = chapter.ImageUrl;
|
||||
if (string.IsNullOrEmpty(imageUrl) && mediaComposition.Show != null)
|
||||
@@ -476,9 +474,10 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
_logger.LogWarning("URN {Urn}: No image URL available for '{Title}'", urn, chapter.Title);
|
||||
}
|
||||
|
||||
// Use ValidFrom for premiere date if this is an upcoming livestream, otherwise use Date
|
||||
var premiereDate = isUpcomingLivestream ? chapter.ValidFrom?.ToUniversalTime() : chapter.Date?.ToUniversalTime();
|
||||
// Use ValidFrom for premiere date if this is a scheduled livestream, otherwise use Date
|
||||
var premiereDate = chapter.Type == "SCHEDULED_LIVESTREAM" ? chapter.ValidFrom?.ToUniversalTime() : chapter.Date?.ToUniversalTime();
|
||||
|
||||
// Store unauthenticated URL as placeholder - SRFMediaProvider will provide authenticated version at playback
|
||||
var item = new ChannelItemInfo
|
||||
{
|
||||
Id = itemId,
|
||||
@@ -502,14 +501,14 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
{
|
||||
Id = itemId,
|
||||
Name = chapter.Title,
|
||||
Path = streamUrl,
|
||||
Path = streamUrl, // Unauthenticated URL - placeholder only
|
||||
Protocol = MediaBrowser.Model.MediaInfo.MediaProtocol.Http,
|
||||
Container = "m3u8",
|
||||
SupportsDirectStream = true,
|
||||
SupportsDirectPlay = true,
|
||||
SupportsTranscoding = true,
|
||||
SupportsDirectPlay = false, // Disable direct play - requires auth from provider
|
||||
SupportsDirectStream = false, // Disable direct stream - requires auth from provider
|
||||
SupportsTranscoding = false, // Force use of IMediaSourceProvider
|
||||
IsRemote = true,
|
||||
Type = MediaBrowser.Model.Dto.MediaSourceType.Default,
|
||||
Type = MediaBrowser.Model.Dto.MediaSourceType.Placeholder, // Mark as placeholder
|
||||
VideoType = VideoType.VideoFile
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user