Add nightly job
This commit is contained in:
@@ -20,7 +20,6 @@ namespace Jellyfin.Plugin.SRFPlay.Api;
|
||||
/// </summary>
|
||||
public class SRFApiClient : IDisposable
|
||||
{
|
||||
private static readonly System.Text.CompositeFormat PlayV3UrlFormat = System.Text.CompositeFormat.Parse(ApiEndpoints.PlayV3BaseUrlTemplate);
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly HttpClient _playV3HttpClient;
|
||||
private readonly ILogger _logger;
|
||||
@@ -58,6 +57,21 @@ public class SRFApiClient : IDisposable
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the Play v3 API base URL for a business unit. The host is normally
|
||||
/// www.<unit>.ch, but SWI's site lives at www.swissinfo.ch (www.swi.ch is an
|
||||
/// unrelated welding institute), while the API path segment stays the unit code.
|
||||
/// </summary>
|
||||
/// <param name="businessUnit">The lowercase business unit (e.g. "srf", "swi").</param>
|
||||
/// <returns>The Play v3 production base URL ending in a slash.</returns>
|
||||
private static string BuildPlayV3BaseUrl(string businessUnit)
|
||||
{
|
||||
var host = string.Equals(businessUnit, "swi", StringComparison.OrdinalIgnoreCase)
|
||||
? "www.swissinfo.ch"
|
||||
: $"www.{businessUnit}.ch";
|
||||
return $"https://{host}/play/v3/api/{businessUnit}/production/";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads HTTP response content as UTF-8 string.
|
||||
/// </summary>
|
||||
@@ -315,7 +329,7 @@ public class SRFApiClient : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseUrl = string.Format(CultureInfo.InvariantCulture, PlayV3UrlFormat, businessUnit);
|
||||
var baseUrl = BuildPlayV3BaseUrl(businessUnit);
|
||||
var url = $"{baseUrl}{endpoint}";
|
||||
_logger.LogInformation("Fetching all {Endpoint} for business unit: {BusinessUnit} from URL: {Url}", endpoint, businessUnit, url);
|
||||
|
||||
@@ -352,7 +366,7 @@ public class SRFApiClient : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseUrl = string.Format(CultureInfo.InvariantCulture, PlayV3UrlFormat, businessUnit);
|
||||
var baseUrl = BuildPlayV3BaseUrl(businessUnit);
|
||||
var url = $"{baseUrl}videos-by-show-id?showId={showId}";
|
||||
_logger.LogDebug("Fetching videos for show {ShowId} from business unit: {BusinessUnit}", showId, businessUnit);
|
||||
|
||||
@@ -392,7 +406,7 @@ public class SRFApiClient : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseUrl = string.Format(CultureInfo.InvariantCulture, PlayV3UrlFormat, businessUnit);
|
||||
var baseUrl = BuildPlayV3BaseUrl(businessUnit);
|
||||
var url = $"{baseUrl}livestreams?eventType={eventType.ToUpperInvariant()}";
|
||||
_logger.LogInformation("Fetching scheduled livestreams for eventType={EventType} from business unit: {BusinessUnit}", eventType, businessUnit);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user