Add IPTV playlist functionality and enhance streaming endpoints
ci / build-backend (push) Successful in 1m47s
ci / build-frontend (push) Successful in 52s
ci / tests (push) Successful in 1m36s
ci / sonar (push) Successful in 4m26s

Implemented a new endpoint for downloading the IPTV playlist, allowing users to access a comprehensive M3U file containing all channels and program guides. Updated the StreamingEndpoints to support token validation for both cookie and query parameters, ensuring secure access for external IPTV players. Enhanced the AirPage component to include a download button for the IPTV playlist, with appropriate user feedback on success or failure. Updated localization strings to reflect new features and instructions for users.
This commit is contained in:
Leonid Pershin
2026-07-29 18:14:01 +03:00
parent 775f287c29
commit c4a94443f7
14 changed files with 535 additions and 13 deletions
@@ -21,11 +21,24 @@ public sealed class StreamTokenService(
private readonly TimeSpan _ttl = TimeSpan.FromMinutes(
Math.Max(1, streamingOptions.Value.StreamTokenMinutes)
);
private readonly TimeSpan _iptvTtl = TimeSpan.FromDays(
Math.Max(1, streamingOptions.Value.IptvTokenDays)
);
private readonly byte[] _key = Encoding.UTF8.GetBytes(jwtOptions.Value.SigningKey);
public (string Token, DateTimeOffset ExpiresAt) Issue(Guid userId)
public (string Token, DateTimeOffset ExpiresAt) Issue(Guid userId) => Issue(userId, _ttl);
/// <summary>
/// Долгий токен для IPTV-плейлиста. Отдельного вида у него нет намеренно: он попадает в те же
/// ссылки на плейлист и сегменты, что и cookie, и проверяется тем же <see cref="Validate"/>.
/// Отличается только сроком — внешний плеер перевыпустить пропуск не может.
/// </summary>
public (string Token, DateTimeOffset ExpiresAt) IssueForIptv(Guid userId) =>
Issue(userId, _iptvTtl);
private (string Token, DateTimeOffset ExpiresAt) Issue(Guid userId, TimeSpan ttl)
{
var expiresAt = DateTimeOffset.UtcNow.Add(_ttl);
var expiresAt = DateTimeOffset.UtcNow.Add(ttl);
var payload = $"{userId:N}.{expiresAt.ToUnixTimeSeconds()}";
var token = $"{Base64Url(Encoding.UTF8.GetBytes(payload))}.{Base64Url(Sign(payload))}";
return (token, expiresAt);