working livestreams!
This commit is contained in:
@@ -100,12 +100,17 @@ public class StreamProxyService : IDisposable
|
||||
/// <returns>The authenticated URL, or null if not found or expired.</returns>
|
||||
public string? GetAuthenticatedUrl(string itemId)
|
||||
{
|
||||
_logger.LogInformation("GetAuthenticatedUrl called for itemId: {ItemId}", itemId);
|
||||
|
||||
// Try direct lookup first
|
||||
if (_streamMappings.TryGetValue(itemId, out var streamInfo))
|
||||
{
|
||||
_logger.LogInformation("✅ Found stream by direct lookup for itemId: {ItemId}", itemId);
|
||||
return ValidateAndReturnStream(itemId, streamInfo);
|
||||
}
|
||||
|
||||
_logger.LogWarning("❌ No direct match for itemId: {ItemId}, trying fallbacks... (Registered streams: {Count})", itemId, _streamMappings.Count);
|
||||
|
||||
// Fallback: Try to find by GUID variations (with/without dashes)
|
||||
// This handles cases where Jellyfin uses different GUID formats
|
||||
var normalizedId = NormalizeGuid(itemId);
|
||||
@@ -403,17 +408,14 @@ public class StreamProxyService : IDisposable
|
||||
var baseUri = new Uri(originalBaseUrl);
|
||||
var baseUrl = $"{baseUri.Scheme}://{baseUri.Host}{string.Join('/', baseUri.AbsolutePath.Split('/')[..^1])}";
|
||||
|
||||
// Extract itemId query parameter from proxyBaseUrl to propagate it
|
||||
var itemIdParam = string.Empty;
|
||||
var queryMarker = "?itemId=";
|
||||
if (proxyBaseUrl.Contains(queryMarker, StringComparison.Ordinal))
|
||||
// Extract query parameters from proxyBaseUrl to propagate them
|
||||
var queryParams = string.Empty;
|
||||
var queryStart = proxyBaseUrl.IndexOf('?', StringComparison.Ordinal);
|
||||
if (queryStart >= 0)
|
||||
{
|
||||
var queryStart = proxyBaseUrl.IndexOf(queryMarker, StringComparison.Ordinal);
|
||||
if (queryStart >= 0)
|
||||
{
|
||||
itemIdParam = proxyBaseUrl[queryStart..];
|
||||
proxyBaseUrl = proxyBaseUrl[..queryStart]; // Remove query from base URL
|
||||
}
|
||||
queryParams = proxyBaseUrl[queryStart..];
|
||||
proxyBaseUrl = proxyBaseUrl[..queryStart]; // Remove query from base URL
|
||||
_logger.LogDebug("Extracted query parameters from proxy URL: {QueryParams}", queryParams);
|
||||
}
|
||||
|
||||
// Pattern to match .m3u8 and .ts/.mp4 segment references
|
||||
@@ -429,11 +431,11 @@ public class StreamProxyService : IDisposable
|
||||
{
|
||||
// Rewrite absolute URLs to proxy
|
||||
var relativePath = url.Replace(baseUrl + "/", string.Empty, StringComparison.Ordinal);
|
||||
return $"\n{proxyBaseUrl}/{relativePath}{itemIdParam}";
|
||||
return $"\n{proxyBaseUrl}/{relativePath}{queryParams}";
|
||||
}
|
||||
|
||||
// Relative URL - rewrite to proxy
|
||||
return $"\n{proxyBaseUrl}/{url}{itemIdParam}";
|
||||
return $"\n{proxyBaseUrl}/{url}{queryParams}";
|
||||
});
|
||||
|
||||
return rewritten;
|
||||
|
||||
Reference in New Issue
Block a user