Merge pull request #6501 from crobibero/schedules-direct

This commit is contained in:
Claus Vium 2021-10-09 23:21:09 +02:00 committed by GitHub
commit 8fc4a48070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 535 additions and 245 deletions

View file

@ -9,14 +9,15 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Cryptography;
@ -34,7 +35,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private readonly ILogger<SchedulesDirect> _logger;
private readonly IHttpClientFactory _httpClientFactory;
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
private readonly IApplicationHost _appHost;
private readonly ICryptoProvider _cryptoProvider;
private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
@ -44,12 +44,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public SchedulesDirect(
ILogger<SchedulesDirect> logger,
IHttpClientFactory httpClientFactory,
IApplicationHost appHost,
ICryptoProvider cryptoProvider)
{
_logger = logger;
_httpClientFactory = httpClientFactory;
_appHost = appHost;
_cryptoProvider = cryptoProvider;
}
@ -114,18 +112,29 @@ namespace Emby.Server.Implementations.LiveTv.Listings
options.Headers.TryAddWithoutValidation("token", token);
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var dailySchedules = await JsonSerializer.DeserializeAsync<List<DayDto>>(responseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
var dailySchedules = await JsonSerializer.DeserializeAsync<IReadOnlyList<DayDto>>(responseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (dailySchedules == null)
{
return Array.Empty<ProgramInfo>();
}
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
using var programRequestOptions = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/programs");
programRequestOptions.Headers.TryAddWithoutValidation("token", token);
var programsID = dailySchedules.SelectMany(d => d.Programs.Select(s => s.ProgramId)).Distinct();
programRequestOptions.Content = new StringContent("[\"" + string.Join("\", \"", programsID) + "\"]", Encoding.UTF8, MediaTypeNames.Application.Json);
var programIds = dailySchedules.SelectMany(d => d.Programs.Select(s => s.ProgramId)).Distinct();
programRequestOptions.Content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(programIds, _jsonOptions));
programRequestOptions.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var programDetails = await JsonSerializer.DeserializeAsync<List<ProgramDetailsDto>>(innerResponseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
var programDetails = await JsonSerializer.DeserializeAsync<IReadOnlyList<ProgramDetailsDto>>(innerResponseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (programDetails == null)
{
return Array.Empty<ProgramInfo>();
}
var programDict = programDetails.ToDictionary(p => p.ProgramId, y => y);
var programIdsWithImages = programDetails
@ -142,6 +151,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
// schedule.ProgramId + " which says it has images? " +
// programDict[schedule.ProgramId].hasImageArtwork);
if (string.IsNullOrEmpty(schedule.ProgramId))
{
continue;
}
if (images != null)
{
var imageIndex = images.FindIndex(i => i.ProgramId == schedule.ProgramId[..10]);
@ -149,7 +163,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
var programEntry = programDict[schedule.ProgramId];
var allImages = images[imageIndex].Data ?? new List<ImageDataDto>();
var allImages = images[imageIndex].Data;
var imagesWithText = allImages.Where(i => string.Equals(i.Text, "yes", StringComparison.OrdinalIgnoreCase));
var imagesWithoutText = allImages.Where(i => string.Equals(i.Text, "no", StringComparison.OrdinalIgnoreCase));
@ -217,7 +231,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private ProgramInfo GetProgram(string channelId, ProgramDto programInfo, ProgramDetailsDto details)
{
var startAt = GetDate(programInfo.AirDateTime);
if (programInfo.AirDateTime == null)
{
return null;
}
var startAt = programInfo.AirDateTime.Value;
var endAt = startAt.AddSeconds(programInfo.Duration);
var audioType = ProgramAudio.Stereo;
@ -225,21 +244,21 @@ namespace Emby.Server.Implementations.LiveTv.Listings
string newID = programId + "T" + startAt.Ticks + "C" + channelId;
if (programInfo.AudioProperties != null)
if (programInfo.AudioProperties.Count != 0)
{
if (programInfo.AudioProperties.Exists(item => string.Equals(item, "atmos", StringComparison.OrdinalIgnoreCase)))
if (programInfo.AudioProperties.Contains("atmos", StringComparer.OrdinalIgnoreCase))
{
audioType = ProgramAudio.Atmos;
}
else if (programInfo.AudioProperties.Exists(item => string.Equals(item, "dd 5.1", StringComparison.OrdinalIgnoreCase)))
else if (programInfo.AudioProperties.Contains("dd 5.1", StringComparer.OrdinalIgnoreCase))
{
audioType = ProgramAudio.DolbyDigital;
}
else if (programInfo.AudioProperties.Exists(item => string.Equals(item, "dd", StringComparison.OrdinalIgnoreCase)))
else if (programInfo.AudioProperties.Contains("dd", StringComparer.OrdinalIgnoreCase))
{
audioType = ProgramAudio.DolbyDigital;
}
else if (programInfo.AudioProperties.Exists(item => string.Equals(item, "stereo", StringComparison.OrdinalIgnoreCase)))
else if (programInfo.AudioProperties.Contains("stereo", StringComparer.OrdinalIgnoreCase))
{
audioType = ProgramAudio.Stereo;
}
@ -355,9 +374,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
if (!string.IsNullOrWhiteSpace(details.OriginalAirDate))
if (details.OriginalAirDate != null)
{
info.OriginalAirDate = DateTime.Parse(details.OriginalAirDate, CultureInfo.InvariantCulture);
info.OriginalAirDate = details.OriginalAirDate;
info.ProductionYear = info.OriginalAirDate.Value.Year;
}
@ -384,18 +403,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return info;
}
private static DateTime GetDate(string value)
{
var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture);
if (date.Kind != DateTimeKind.Utc)
{
date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
}
return date;
}
private string GetProgramImage(string apiUrl, IEnumerable<ImageDataDto> images, bool returnDefaultImage, double desiredAspect)
{
var match = images
@ -449,14 +456,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return result;
}
private async Task<List<ShowImagesDto>> GetImageForPrograms(
private async Task<IReadOnlyList<ShowImagesDto>> GetImageForPrograms(
ListingsProviderInfo info,
IReadOnlyList<string> programIds,
CancellationToken cancellationToken)
{
if (programIds.Count == 0)
{
return new List<ShowImagesDto>();
return Array.Empty<ShowImagesDto>();
}
StringBuilder str = new StringBuilder("[", 1 + (programIds.Count * 13));
@ -480,13 +487,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);
await using var response = await innerResponse2.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return await JsonSerializer.DeserializeAsync<List<ShowImagesDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
return await JsonSerializer.DeserializeAsync<IReadOnlyList<ShowImagesDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting image info from schedules direct");
return new List<ShowImagesDto>();
return Array.Empty<ShowImagesDto>();
}
}
@ -509,7 +516,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var httpResponse = await Send(options, false, info, cancellationToken).ConfigureAwait(false);
await using var response = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<List<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<IReadOnlyList<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (root != null)
{
@ -520,7 +527,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
lineups.Add(new NameIdPair
{
Name = string.IsNullOrWhiteSpace(lineup.Name) ? lineup.Lineup : lineup.Name,
Id = lineup.Uri[18..]
Id = lineup.Uri?[18..]
});
}
}
@ -651,7 +658,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
response.EnsureSuccessStatusCode();
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<TokenDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (string.Equals(root.Message, "OK", StringComparison.Ordinal))
if (string.Equals(root?.Message, "OK", StringComparison.Ordinal))
{
_logger.LogInformation("Authenticated with Schedules Direct token: {Token}", root.Token);
return root.Token;
@ -708,12 +715,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var response = httpResponse.Content;
var root = await JsonSerializer.DeserializeAsync<LineupsDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
return root.Lineups.Any(i => string.Equals(info.ListingsId, i.Lineup, StringComparison.OrdinalIgnoreCase));
return root?.Lineups.Any(i => string.Equals(info.ListingsId, i.Lineup, StringComparison.OrdinalIgnoreCase)) ?? false;
}
catch (HttpRequestException ex)
{
// SchedulesDirect returns 400 if no lineups are configured.
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.BadRequest)
if (ex.StatusCode is HttpStatusCode.BadRequest)
{
return false;
}
@ -779,10 +786,15 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<ChannelDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (root == null)
{
return new List<ChannelInfo>();
}
_logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.Map.Count);
_logger.LogInformation("Mapping Stations to Channel");
var allStations = root.Stations ?? new List<StationDto>();
var allStations = root.Stations;
var map = root.Map;
var list = new List<ChannelInfo>(map.Count);
@ -790,11 +802,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
var channelNumber = GetChannelNumber(channel);
var station = allStations.Find(item => string.Equals(item.StationId, channel.StationId, StringComparison.OrdinalIgnoreCase))
?? new StationDto
{
StationId = channel.StationId
};
var stationIndex = allStations.FindIndex(item => string.Equals(item.StationId, channel.StationId, StringComparison.OrdinalIgnoreCase));
var station = stationIndex == -1
? new StationDto { StationId = channel.StationId }
: allStations[stationIndex];
var channelInfo = new ChannelInfo
{

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,24 +11,24 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the city.
/// </summary>
[JsonPropertyName("city")]
public string City { get; set; }
public string? City { get; set; }
/// <summary>
/// Gets or sets the state.
/// </summary>
[JsonPropertyName("state")]
public string State { get; set; }
public string? State { get; set; }
/// <summary>
/// Gets or sets the postal code.
/// </summary>
[JsonPropertyName("postalCode")]
public string Postalcode { get; set; }
public string? Postalcode { get; set; }
/// <summary>
/// Gets or sets the country.
/// </summary>
[JsonPropertyName("country")]
public string Country { get; set; }
public string? Country { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the content.
/// </summary>
[JsonPropertyName("content")]
public string Content { get; set; }
public string? Content { get; set; }
/// <summary>
/// Gets or sets the lang.
/// </summary>
[JsonPropertyName("lang")]
public string Lang { get; set; }
public string? Lang { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,36 +11,36 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the billing order.
/// </summary>
[JsonPropertyName("billingOrder")]
public string BillingOrder { get; set; }
public string? BillingOrder { get; set; }
/// <summary>
/// Gets or sets the role.
/// </summary>
[JsonPropertyName("role")]
public string Role { get; set; }
public string? Role { get; set; }
/// <summary>
/// Gets or sets the name id.
/// </summary>
[JsonPropertyName("nameId")]
public string NameId { get; set; }
public string? NameId { get; set; }
/// <summary>
/// Gets or sets the person id.
/// </summary>
[JsonPropertyName("personId")]
public string PersonId { get; set; }
public string? PersonId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
/// <summary>
/// Gets or sets the character name.
/// </summary>
[JsonPropertyName("characterName")]
public string CharacterName { get; set; }
public string? CharacterName { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,18 +13,18 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the list of maps.
/// </summary>
[JsonPropertyName("map")]
public List<MapDto> Map { get; set; }
public IReadOnlyList<MapDto> Map { get; set; } = Array.Empty<MapDto>();
/// <summary>
/// Gets or sets the list of stations.
/// </summary>
[JsonPropertyName("stations")]
public List<StationDto> Stations { get; set; }
public IReadOnlyList<StationDto> Stations { get; set; } = Array.Empty<StationDto>();
/// <summary>
/// Gets or sets the metadata.
/// </summary>
[JsonPropertyName("metadata")]
public MetadataDto Metadata { get; set; }
public MetadataDto? Metadata { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the body.
/// </summary>
[JsonPropertyName("body")]
public string Body { get; set; }
public string? Body { get; set; }
/// <summary>
/// Gets or sets the code.
/// </summary>
[JsonPropertyName("code")]
public string Code { get; set; }
public string? Code { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,30 +11,30 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the billing order.
/// </summary>
[JsonPropertyName("billingOrder")]
public string BillingOrder { get; set; }
public string? BillingOrder { get; set; }
/// <summary>
/// Gets or sets the role.
/// </summary>
[JsonPropertyName("role")]
public string Role { get; set; }
public string? Role { get; set; }
/// <summary>
/// Gets or sets the name id.
/// </summary>
[JsonPropertyName("nameId")]
public string NameId { get; set; }
public string? NameId { get; set; }
/// <summary>
/// Gets or sets the person id.
/// </summary>
[JsonPropertyName("personId")]
public string PersonId { get; set; }
public string? PersonId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -10,30 +9,22 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// </summary>
public class DayDto
{
/// <summary>
/// Initializes a new instance of the <see cref="DayDto"/> class.
/// </summary>
public DayDto()
{
Programs = new List<ProgramDto>();
}
/// <summary>
/// Gets or sets the station id.
/// </summary>
[JsonPropertyName("stationID")]
public string StationId { get; set; }
public string? StationId { get; set; }
/// <summary>
/// Gets or sets the list of programs.
/// </summary>
[JsonPropertyName("programs")]
public List<ProgramDto> Programs { get; set; }
public IReadOnlyList<ProgramDto> Programs { get; set; } = Array.Empty<ProgramDto>();
/// <summary>
/// Gets or sets the metadata schedule.
/// </summary>
[JsonPropertyName("metadata")]
public MetadataScheduleDto Metadata { get; set; }
public MetadataScheduleDto? Metadata { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the description language.
/// </summary>
[JsonPropertyName("descriptionLanguage")]
public string DescriptionLanguage { get; set; }
public string? DescriptionLanguage { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
[JsonPropertyName("description")]
public string Description { get; set; }
public string? Description { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the description language.
/// </summary>
[JsonPropertyName("descriptionLanguage")]
public string DescriptionLanguage { get; set; }
public string? DescriptionLanguage { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
[JsonPropertyName("description")]
public string Description { get; set; }
public string? Description { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,12 +13,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the list of description 100.
/// </summary>
[JsonPropertyName("description100")]
public List<Description100Dto> Description100 { get; set; }
public IReadOnlyList<Description100Dto> Description100 { get; set; } = Array.Empty<Description100Dto>();
/// <summary>
/// Gets or sets the list of description1000.
/// </summary>
[JsonPropertyName("description1000")]
public List<Description1000Dto> Description1000 { get; set; }
public IReadOnlyList<Description1000Dto> Description1000 { get; set; } = Array.Empty<Description1000Dto>();
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,6 +11,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the sub type.
/// </summary>
[JsonPropertyName("subType")]
public string SubType { get; set; }
public string? SubType { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,24 +13,24 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the headend.
/// </summary>
[JsonPropertyName("headend")]
public string Headend { get; set; }
public string? Headend { get; set; }
/// <summary>
/// Gets or sets the transport.
/// </summary>
[JsonPropertyName("transport")]
public string Transport { get; set; }
public string? Transport { get; set; }
/// <summary>
/// Gets or sets the location.
/// </summary>
[JsonPropertyName("location")]
public string Location { get; set; }
public string? Location { get; set; }
/// <summary>
/// Gets or sets the list of lineups.
/// </summary>
[JsonPropertyName("lineups")]
public List<LineupDto> Lineups { get; set; }
public IReadOnlyList<LineupDto> Lineups { get; set; } = Array.Empty<LineupDto>();
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,60 +11,60 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the width.
/// </summary>
[JsonPropertyName("width")]
public string Width { get; set; }
public string? Width { get; set; }
/// <summary>
/// Gets or sets the height.
/// </summary>
[JsonPropertyName("height")]
public string Height { get; set; }
public string? Height { get; set; }
/// <summary>
/// Gets or sets the uri.
/// </summary>
[JsonPropertyName("uri")]
public string Uri { get; set; }
public string? Uri { get; set; }
/// <summary>
/// Gets or sets the size.
/// </summary>
[JsonPropertyName("size")]
public string Size { get; set; }
public string? Size { get; set; }
/// <summary>
/// Gets or sets the aspect.
/// </summary>
[JsonPropertyName("aspect")]
public string Aspect { get; set; }
public string? Aspect { get; set; }
/// <summary>
/// Gets or sets the category.
/// </summary>
[JsonPropertyName("category")]
public string Category { get; set; }
public string? Category { get; set; }
/// <summary>
/// Gets or sets the text.
/// </summary>
[JsonPropertyName("text")]
public string Text { get; set; }
public string? Text { get; set; }
/// <summary>
/// Gets or sets the primary.
/// </summary>
[JsonPropertyName("primary")]
public string Primary { get; set; }
public string? Primary { get; set; }
/// <summary>
/// Gets or sets the tier.
/// </summary>
[JsonPropertyName("tier")]
public string Tier { get; set; }
public string? Tier { get; set; }
/// <summary>
/// Gets or sets the caption.
/// </summary>
[JsonPropertyName("caption")]
public CaptionDto Caption { get; set; }
public CaptionDto? Caption { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,30 +11,36 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the linup.
/// </summary>
[JsonPropertyName("lineup")]
public string Lineup { get; set; }
public string? Lineup { get; set; }
/// <summary>
/// Gets or sets the lineup name.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
/// <summary>
/// Gets or sets the transport.
/// </summary>
[JsonPropertyName("transport")]
public string Transport { get; set; }
public string? Transport { get; set; }
/// <summary>
/// Gets or sets the location.
/// </summary>
[JsonPropertyName("location")]
public string Location { get; set; }
public string? Location { get; set; }
/// <summary>
/// Gets or sets the uri.
/// </summary>
[JsonPropertyName("uri")]
public string Uri { get; set; }
public string? Uri { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this lineup was deleted.
/// </summary>
[JsonPropertyName("isDeleted")]
public bool? IsDeleted { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -20,18 +19,18 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the server id.
/// </summary>
[JsonPropertyName("serverID")]
public string ServerId { get; set; }
public string? ServerId { get; set; }
/// <summary>
/// Gets or sets the datetime.
/// </summary>
[JsonPropertyName("datetime")]
public string Datetime { get; set; }
public DateTime? LineupTimestamp { get; set; }
/// <summary>
/// Gets or sets the list of lineups.
/// </summary>
[JsonPropertyName("lineups")]
public List<LineupDto> Lineups { get; set; }
public IReadOnlyList<LineupDto> Lineups { get; set; } = Array.Empty<LineupDto>();
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,7 +11,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the url.
/// </summary>
[JsonPropertyName("URL")]
public string Url { get; set; }
public string? Url { get; set; }
/// <summary>
/// Gets or sets the height.
@ -31,6 +29,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the md5.
/// </summary>
[JsonPropertyName("md5")]
public string Md5 { get; set; }
public string? Md5 { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,19 +11,25 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the station id.
/// </summary>
[JsonPropertyName("stationID")]
public string StationId { get; set; }
public string? StationId { get; set; }
/// <summary>
/// Gets or sets the channel.
/// </summary>
[JsonPropertyName("channel")]
public string Channel { get; set; }
public string? Channel { get; set; }
/// <summary>
/// Gets or sets the provider callsign.
/// </summary>
[JsonPropertyName("providerCallsign")]
public string? ProvderCallsign { get; set; }
/// <summary>
/// Gets or sets the logical channel number.
/// </summary>
[JsonPropertyName("logicalChannelNumber")]
public string LogicalChannelNumber { get; set; }
public string? LogicalChannelNumber { get; set; }
/// <summary>
/// Gets or sets the uhfvhf.
@ -44,5 +48,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// </summary>
[JsonPropertyName("atscMinor")]
public int AtscMinor { get; set; }
/// <summary>
/// Gets or sets the match type.
/// </summary>
[JsonPropertyName("matchType")]
public string? MatchType { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,18 +11,18 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the linup.
/// </summary>
[JsonPropertyName("lineup")]
public string Lineup { get; set; }
public string? Lineup { get; set; }
/// <summary>
/// Gets or sets the modified timestamp.
/// </summary>
[JsonPropertyName("modified")]
public string Modified { get; set; }
public string? Modified { get; set; }
/// <summary>
/// Gets or sets the transport.
/// </summary>
[JsonPropertyName("transport")]
public string Transport { get; set; }
public string? Transport { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -12,7 +10,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// <summary>
/// Gets or sets the gracenote object.
/// </summary>
[JsonPropertyName("gracenote")]
public GracenoteDto Gracenote { get; set; }
[JsonPropertyName("Gracenote")]
public GracenoteDto? Gracenote { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,25 +12,25 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the modified timestamp.
/// </summary>
[JsonPropertyName("modified")]
public string Modified { get; set; }
public string? Modified { get; set; }
/// <summary>
/// Gets or sets the md5.
/// </summary>
[JsonPropertyName("md5")]
public string Md5 { get; set; }
public string? Md5 { get; set; }
/// <summary>
/// Gets or sets the start date.
/// </summary>
[JsonPropertyName("startDate")]
public string StartDate { get; set; }
public DateTime? StartDate { get; set; }
/// <summary>
/// Gets or sets the end date.
/// </summary>
[JsonPropertyName("endDate")]
public string EndDate { get; set; }
public DateTime? EndDate { get; set; }
/// <summary>
/// Gets or sets the days count.

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,7 +13,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the year.
/// </summary>
[JsonPropertyName("year")]
public string Year { get; set; }
public string? Year { get; set; }
/// <summary>
/// Gets or sets the duration.
@ -26,6 +25,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the list of quality rating.
/// </summary>
[JsonPropertyName("qualityRating")]
public List<QualityRatingDto> QualityRating { get; set; }
public IReadOnlyList<QualityRatingDto> QualityRating { get; set; } = Array.Empty<QualityRatingDto>();
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,85 +13,85 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the audience.
/// </summary>
[JsonPropertyName("audience")]
public string Audience { get; set; }
public string? Audience { get; set; }
/// <summary>
/// Gets or sets the program id.
/// </summary>
[JsonPropertyName("programID")]
public string ProgramId { get; set; }
public string? ProgramId { get; set; }
/// <summary>
/// Gets or sets the list of titles.
/// </summary>
[JsonPropertyName("titles")]
public List<TitleDto> Titles { get; set; }
public IReadOnlyList<TitleDto> Titles { get; set; } = Array.Empty<TitleDto>();
/// <summary>
/// Gets or sets the event details object.
/// </summary>
[JsonPropertyName("eventDetails")]
public EventDetailsDto EventDetails { get; set; }
public EventDetailsDto? EventDetails { get; set; }
/// <summary>
/// Gets or sets the descriptions.
/// </summary>
[JsonPropertyName("descriptions")]
public DescriptionsProgramDto Descriptions { get; set; }
public DescriptionsProgramDto? Descriptions { get; set; }
/// <summary>
/// Gets or sets the original air date.
/// </summary>
[JsonPropertyName("originalAirDate")]
public string OriginalAirDate { get; set; }
public DateTime? OriginalAirDate { get; set; }
/// <summary>
/// Gets or sets the list of genres.
/// </summary>
[JsonPropertyName("genres")]
public List<string> Genres { get; set; }
public IReadOnlyList<string> Genres { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the episode title.
/// </summary>
[JsonPropertyName("episodeTitle150")]
public string EpisodeTitle150 { get; set; }
public string? EpisodeTitle150 { get; set; }
/// <summary>
/// Gets or sets the list of metadata.
/// </summary>
[JsonPropertyName("metadata")]
public List<MetadataProgramsDto> Metadata { get; set; }
public IReadOnlyList<MetadataProgramsDto> Metadata { get; set; } = Array.Empty<MetadataProgramsDto>();
/// <summary>
/// Gets or sets the list of content raitings.
/// </summary>
[JsonPropertyName("contentRating")]
public List<ContentRatingDto> ContentRating { get; set; }
public IReadOnlyList<ContentRatingDto> ContentRating { get; set; } = Array.Empty<ContentRatingDto>();
/// <summary>
/// Gets or sets the list of cast.
/// </summary>
[JsonPropertyName("cast")]
public List<CastDto> Cast { get; set; }
public IReadOnlyList<CastDto> Cast { get; set; } = Array.Empty<CastDto>();
/// <summary>
/// Gets or sets the list of crew.
/// </summary>
[JsonPropertyName("crew")]
public List<CrewDto> Crew { get; set; }
public IReadOnlyList<CrewDto> Crew { get; set; } = Array.Empty<CrewDto>();
/// <summary>
/// Gets or sets the entity type.
/// </summary>
[JsonPropertyName("entityType")]
public string EntityType { get; set; }
public string? EntityType { get; set; }
/// <summary>
/// Gets or sets the show type.
/// </summary>
[JsonPropertyName("showType")]
public string ShowType { get; set; }
public string? ShowType { get; set; }
/// <summary>
/// Gets or sets a value indicating whether there is image artwork.
@ -104,54 +103,54 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the primary image.
/// </summary>
[JsonPropertyName("primaryImage")]
public string PrimaryImage { get; set; }
public string? PrimaryImage { get; set; }
/// <summary>
/// Gets or sets the thumb image.
/// </summary>
[JsonPropertyName("thumbImage")]
public string ThumbImage { get; set; }
public string? ThumbImage { get; set; }
/// <summary>
/// Gets or sets the backdrop image.
/// </summary>
[JsonPropertyName("backdropImage")]
public string BackdropImage { get; set; }
public string? BackdropImage { get; set; }
/// <summary>
/// Gets or sets the banner image.
/// </summary>
[JsonPropertyName("bannerImage")]
public string BannerImage { get; set; }
public string? BannerImage { get; set; }
/// <summary>
/// Gets or sets the image id.
/// </summary>
[JsonPropertyName("imageID")]
public string ImageId { get; set; }
public string? ImageId { get; set; }
/// <summary>
/// Gets or sets the md5.
/// </summary>
[JsonPropertyName("md5")]
public string Md5 { get; set; }
public string? Md5 { get; set; }
/// <summary>
/// Gets or sets the list of content advisory.
/// </summary>
[JsonPropertyName("contentAdvisory")]
public List<string> ContentAdvisory { get; set; }
public IReadOnlyList<string> ContentAdvisory { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the movie object.
/// </summary>
[JsonPropertyName("movie")]
public MovieDto Movie { get; set; }
public MovieDto? Movie { get; set; }
/// <summary>
/// Gets or sets the list of recommendations.
/// </summary>
[JsonPropertyName("recommendations")]
public List<RecommendationDto> Recommendations { get; set; }
public IReadOnlyList<RecommendationDto> Recommendations { get; set; } = Array.Empty<RecommendationDto>();
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,13 +13,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the program id.
/// </summary>
[JsonPropertyName("programID")]
public string ProgramId { get; set; }
public string? ProgramId { get; set; }
/// <summary>
/// Gets or sets the air date time.
/// </summary>
[JsonPropertyName("airDateTime")]
public string AirDateTime { get; set; }
public DateTime? AirDateTime { get; set; }
/// <summary>
/// Gets or sets the duration.
@ -32,25 +31,25 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the md5.
/// </summary>
[JsonPropertyName("md5")]
public string Md5 { get; set; }
public string? Md5 { get; set; }
/// <summary>
/// Gets or sets the list of audio properties.
/// </summary>
[JsonPropertyName("audioProperties")]
public List<string> AudioProperties { get; set; }
public IReadOnlyList<string> AudioProperties { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the list of video properties.
/// </summary>
[JsonPropertyName("videoProperties")]
public List<string> VideoProperties { get; set; }
public IReadOnlyList<string> VideoProperties { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the list of ratings.
/// </summary>
[JsonPropertyName("ratings")]
public List<RatingDto> Ratings { get; set; }
public IReadOnlyList<RatingDto> Ratings { get; set; } = Array.Empty<RatingDto>();
/// <summary>
/// Gets or sets a value indicating whether this program is new.
@ -62,13 +61,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the multipart object.
/// </summary>
[JsonPropertyName("multipart")]
public MultipartDto Multipart { get; set; }
public MultipartDto? Multipart { get; set; }
/// <summary>
/// Gets or sets the live tape delay.
/// </summary>
[JsonPropertyName("liveTapeDelay")]
public string LiveTapeDelay { get; set; }
public string? LiveTapeDelay { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this is the premiere.
@ -86,6 +85,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the premiere or finale.
/// </summary>
[JsonPropertyName("isPremiereOrFinale")]
public string IsPremiereOrFinale { get; set; }
public string? IsPremiereOrFinale { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,30 +11,30 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the ratings body.
/// </summary>
[JsonPropertyName("ratingsBody")]
public string RatingsBody { get; set; }
public string? RatingsBody { get; set; }
/// <summary>
/// Gets or sets the rating.
/// </summary>
[JsonPropertyName("rating")]
public string Rating { get; set; }
public string? Rating { get; set; }
/// <summary>
/// Gets or sets the min rating.
/// </summary>
[JsonPropertyName("minRating")]
public string MinRating { get; set; }
public string? MinRating { get; set; }
/// <summary>
/// Gets or sets the max rating.
/// </summary>
[JsonPropertyName("maxRating")]
public string MaxRating { get; set; }
public string? MaxRating { get; set; }
/// <summary>
/// Gets or sets the increment.
/// </summary>
[JsonPropertyName("increment")]
public string Increment { get; set; }
public string? Increment { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the body.
/// </summary>
[JsonPropertyName("body")]
public string Body { get; set; }
public string? Body { get; set; }
/// <summary>
/// Gets or sets the code.
/// </summary>
[JsonPropertyName("code")]
public string Code { get; set; }
public string? Code { get; set; }
}
}

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,12 +11,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the program id.
/// </summary>
[JsonPropertyName("programID")]
public string ProgramId { get; set; }
public string? ProgramId { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
[JsonPropertyName("title120")]
public string Title120 { get; set; }
public string? Title120 { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,12 +13,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the station id.
/// </summary>
[JsonPropertyName("stationID")]
public string StationId { get; set; }
public string? StationId { get; set; }
/// <summary>
/// Gets or sets the list of dates.
/// </summary>
[JsonPropertyName("date")]
public List<string> Date { get; set; }
public IReadOnlyList<string> Date { get; set; } = Array.Empty<string>();
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,12 +13,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the program id.
/// </summary>
[JsonPropertyName("programID")]
public string ProgramId { get; set; }
public string? ProgramId { get; set; }
/// <summary>
/// Gets or sets the list of data.
/// </summary>
[JsonPropertyName("data")]
public List<ImageDataDto> Data { get; set; }
public IReadOnlyList<ImageDataDto> Data { get; set; } = Array.Empty<ImageDataDto>();
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -14,49 +13,49 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the station id.
/// </summary>
[JsonPropertyName("stationID")]
public string StationId { get; set; }
public string? StationId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
/// <summary>
/// Gets or sets the callsign.
/// </summary>
[JsonPropertyName("callsign")]
public string Callsign { get; set; }
public string? Callsign { get; set; }
/// <summary>
/// Gets or sets the broadcast language.
/// </summary>
[JsonPropertyName("broadcastLanguage")]
public List<string> BroadcastLanguage { get; set; }
public IReadOnlyList<string> BroadcastLanguage { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the description language.
/// </summary>
[JsonPropertyName("descriptionLanguage")]
public List<string> DescriptionLanguage { get; set; }
public IReadOnlyList<string> DescriptionLanguage { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the broadcaster.
/// </summary>
[JsonPropertyName("broadcaster")]
public BroadcasterDto Broadcaster { get; set; }
public BroadcasterDto? Broadcaster { get; set; }
/// <summary>
/// Gets or sets the affiliate.
/// </summary>
[JsonPropertyName("affiliate")]
public string Affiliate { get; set; }
public string? Affiliate { get; set; }
/// <summary>
/// Gets or sets the logo.
/// </summary>
[JsonPropertyName("logo")]
public LogoDto Logo { get; set; }
public LogoDto? Logo { get; set; }
/// <summary>
/// Gets or sets a value indicating whether it is commercial free.

View file

@ -1,5 +1,3 @@
#nullable disable
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -13,6 +11,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the title.
/// </summary>
[JsonPropertyName("title120")]
public string Title120 { get; set; }
public string? Title120 { get; set; }
}
}

View file

@ -1,5 +1,4 @@
#nullable disable
using System;
using System.Text.Json.Serialization;
namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
@ -19,18 +18,30 @@ namespace Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos
/// Gets or sets the response message.
/// </summary>
[JsonPropertyName("message")]
public string Message { get; set; }
public string? Message { get; set; }
/// <summary>
/// Gets or sets the server id.
/// </summary>
[JsonPropertyName("serverID")]
public string ServerId { get; set; }
public string? ServerId { get; set; }
/// <summary>
/// Gets or sets the token.
/// </summary>
[JsonPropertyName("token")]
public string Token { get; set; }
public string? Token { get; set; }
/// <summary>
/// Gets or sets the current datetime.
/// </summary>
[JsonPropertyName("datetime")]
public DateTime? TokenTimestamp { get; set; }
/// <summary>
/// Gets or sets the response message.
/// </summary>
[JsonPropertyName("response")]
public string? Response { get; set; }
}
}

View file

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
namespace Jellyfin.Extensions
{
/// <summary>
/// Static extensions for the <see cref="IReadOnlyList{T}"/> interface.
/// </summary>
public static class ReadOnlyListExtension
{
/// <summary>
/// Finds the index of the desired item.
/// </summary>
/// <param name="source">The source list.</param>
/// <param name="value">The value to fine.</param>
/// <typeparam name="T">The type of item to find.</typeparam>
/// <returns>Index if found, else -1.</returns>
public static int IndexOf<T>(this IReadOnlyList<T> source, T value)
{
if (source is IList<T> list)
{
return list.IndexOf(value);
}
for (int i = 0; i < source.Count; i++)
{
if (Equals(value, source[i]))
{
return i;
}
}
return -1;
}
/// <summary>
/// Finds the index of the predicate.
/// </summary>
/// <param name="source">The source list.</param>
/// <param name="match">The value to find.</param>
/// <typeparam name="T">The type of item to find.</typeparam>
/// <returns>Index if found, else -1.</returns>
public static int FindIndex<T>(this IReadOnlyList<T> source, Predicate<T> match)
{
if (source is List<T> list)
{
return list.FindIndex(match);
}
for (int i = 0; i < source.Count; i++)
{
if (match(source[i]))
{
return i;
}
}
return -1;
}
}
}

View file

@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Emby.Server.Implementations.LiveTv.Listings.SchedulesDirectDtos;
using Jellyfin.Extensions.Json;
using Xunit;
namespace Jellyfin.Server.Implementations.Tests.LiveTv.SchedulesDirect
{
public class SchedulesDirectDeserializeTests
{
private readonly JsonSerializerOptions _jsonOptions;
public SchedulesDirectDeserializeTests()
{
_jsonOptions = JsonDefaults.Options;
}
/// <summary>
/// /token reponse.
/// </summary>
[Fact]
public void Deserialize_Token_Response_Live_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/token_live_response.json");
var tokenDto = JsonSerializer.Deserialize<TokenDto>(bytes, _jsonOptions);
Assert.NotNull(tokenDto);
Assert.Equal(0, tokenDto!.Code);
Assert.Equal("OK", tokenDto.Message);
Assert.Equal("AWS-SD-web.1", tokenDto.ServerId);
Assert.Equal(new DateTime(2016, 08, 23, 13, 55, 25, DateTimeKind.Utc), tokenDto.TokenTimestamp);
Assert.Equal("f3fca79989cafe7dead71beefedc812b", tokenDto.Token);
}
/// <summary>
/// /token response.
/// </summary>
[Fact]
public void Deserialize_Token_Response_Offline_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/token_offline_response.json");
var tokenDto = JsonSerializer.Deserialize<TokenDto>(bytes, _jsonOptions);
Assert.NotNull(tokenDto);
Assert.Equal(3_000, tokenDto!.Code);
Assert.Equal("Server offline for maintenance.", tokenDto.Message);
Assert.Equal("20141201.web.1", tokenDto.ServerId);
Assert.Equal(new DateTime(2015, 04, 23, 00, 03, 32, DateTimeKind.Utc), tokenDto.TokenTimestamp);
Assert.Equal("CAFEDEADBEEFCAFEDEADBEEFCAFEDEADBEEFCAFE", tokenDto.Token);
Assert.Equal("SERVICE_OFFLINE", tokenDto.Response);
}
/// <summary>
/// /schedules request.
/// </summary>
[Fact]
public void Serialize_Schedule_Request_Success()
{
var expectedString = File.ReadAllText("Test Data/SchedulesDirect/schedules_request.json").Trim();
var requestObject = new RequestScheduleForChannelDto[]
{
new RequestScheduleForChannelDto
{
StationId = "20454",
Date = new[]
{
"2015-03-13",
"2015-03-17"
}
},
new RequestScheduleForChannelDto
{
StationId = "10021",
Date = new[]
{
"2015-03-12",
"2015-03-13"
}
}
};
var requestString = JsonSerializer.Serialize(requestObject, _jsonOptions);
Assert.Equal(expectedString, requestString);
}
/// <summary>
/// /schedules response.
/// </summary>
[Fact]
public void Deserialize_Schedule_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/schedules_response.json");
var days = JsonSerializer.Deserialize<IReadOnlyList<DayDto>>(bytes, _jsonOptions);
Assert.NotNull(days);
Assert.Equal(1, days!.Count);
var dayDto = days[0];
Assert.Equal("20454", dayDto.StationId);
Assert.Equal(2, dayDto.Programs.Count);
Assert.Equal("SH005371070000", dayDto.Programs[0].ProgramId);
Assert.Equal(new DateTime(2015, 03, 03, 00, 00, 00, DateTimeKind.Utc), dayDto.Programs[0].AirDateTime);
Assert.Equal(1_800, dayDto.Programs[0].Duration);
Assert.Equal("Sy8HEMBPcuiAx3FBukUhKQ", dayDto.Programs[0].Md5);
Assert.True(dayDto.Programs[0].New);
Assert.Equal(2, dayDto.Programs[0].AudioProperties.Count);
Assert.Equal("stereo", dayDto.Programs[0].AudioProperties[0]);
Assert.Equal("cc", dayDto.Programs[0].AudioProperties[1]);
Assert.Equal(1, dayDto.Programs[0].VideoProperties.Count);
Assert.Equal("hdtv", dayDto.Programs[0].VideoProperties[0]);
}
/// <summary>
/// /programs response.
/// </summary>
[Fact]
public void Deserialize_Program_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/programs_response.json");
var programDtos = JsonSerializer.Deserialize<IReadOnlyList<ProgramDetailsDto>>(bytes, _jsonOptions);
Assert.NotNull(programDtos);
Assert.Equal(2, programDtos!.Count);
Assert.Equal("EP000000060003", programDtos[0].ProgramId);
Assert.Equal(1, programDtos[0].Titles.Count);
Assert.Equal("'Allo 'Allo!", programDtos[0].Titles[0].Title120);
Assert.Equal("Series", programDtos[0].EventDetails?.SubType);
Assert.Equal("en", programDtos[0].Descriptions?.Description1000[0].DescriptionLanguage);
Assert.Equal("A disguised British Intelligence officer is sent to help the airmen.", programDtos[0].Descriptions?.Description1000[0].Description);
Assert.Equal(new DateTime(1985, 11, 04), programDtos[0].OriginalAirDate);
Assert.Equal(1, programDtos[0].Genres.Count);
Assert.Equal("Sitcom", programDtos[0].Genres[0]);
Assert.Equal("The Poloceman Cometh", programDtos[0].EpisodeTitle150);
Assert.Equal(2, programDtos[0].Metadata[0].Gracenote?.Season);
Assert.Equal(3, programDtos[0].Metadata[0].Gracenote?.Episode);
Assert.Equal(13, programDtos[0].Cast.Count);
Assert.Equal("383774", programDtos[0].Cast[0].PersonId);
Assert.Equal("392649", programDtos[0].Cast[0].NameId);
Assert.Equal("Gorden Kaye", programDtos[0].Cast[0].Name);
Assert.Equal("Actor", programDtos[0].Cast[0].Role);
Assert.Equal("01", programDtos[0].Cast[0].BillingOrder);
Assert.Equal(3, programDtos[0].Crew.Count);
Assert.Equal("354407", programDtos[0].Crew[0].PersonId);
Assert.Equal("363281", programDtos[0].Crew[0].NameId);
Assert.Equal("David Croft", programDtos[0].Crew[0].Name);
Assert.Equal("Director", programDtos[0].Crew[0].Role);
Assert.Equal("01", programDtos[0].Crew[0].BillingOrder);
}
/// <summary>
/// /metadata/programs response.
/// </summary>
[Fact]
public void Deserialize_Metadata_Programs_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/metadata_programs_response.json");
var showImagesDtos = JsonSerializer.Deserialize<IReadOnlyList<ShowImagesDto>>(bytes, _jsonOptions);
Assert.NotNull(showImagesDtos);
Assert.Equal(1, showImagesDtos!.Count);
Assert.Equal("SH00712240", showImagesDtos[0].ProgramId);
Assert.Equal(4, showImagesDtos[0].Data.Count);
Assert.Equal("135", showImagesDtos[0].Data[0].Width);
Assert.Equal("180", showImagesDtos[0].Data[0].Height);
Assert.Equal("assets/p282288_b_v2_aa.jpg", showImagesDtos[0].Data[0].Uri);
Assert.Equal("Sm", showImagesDtos[0].Data[0].Size);
Assert.Equal("3x4", showImagesDtos[0].Data[0].Aspect);
Assert.Equal("Banner-L3", showImagesDtos[0].Data[0].Category);
Assert.Equal("yes", showImagesDtos[0].Data[0].Text);
Assert.Equal("true", showImagesDtos[0].Data[0].Primary);
Assert.Equal("Series", showImagesDtos[0].Data[0].Tier);
}
/// <summary>
/// /headends response.
/// </summary>
[Fact]
public void Deserialize_Headends_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/headends_response.json");
var headendsDtos = JsonSerializer.Deserialize<IReadOnlyList<HeadendsDto>>(bytes, _jsonOptions);
Assert.NotNull(headendsDtos);
Assert.Equal(8, headendsDtos!.Count);
Assert.Equal("CA00053", headendsDtos[0].Headend);
Assert.Equal("Cable", headendsDtos[0].Transport);
Assert.Equal("Beverly Hills", headendsDtos[0].Location);
Assert.Equal(2, headendsDtos[0].Lineups.Count);
Assert.Equal("Time Warner Cable - Cable", headendsDtos[0].Lineups[0].Name);
Assert.Equal("USA-CA00053-DEFAULT", headendsDtos[0].Lineups[0].Lineup);
Assert.Equal("/20141201/lineups/USA-CA00053-DEFAULT", headendsDtos[0].Lineups[0].Uri);
}
/// <summary>
/// /lineups response.
/// </summary>
[Fact]
public void Deserialize_Lineups_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/lineups_response.json");
var lineupsDto = JsonSerializer.Deserialize<LineupsDto>(bytes, _jsonOptions);
Assert.NotNull(lineupsDto);
Assert.Equal(0, lineupsDto!.Code);
Assert.Equal("20141201.web.1", lineupsDto.ServerId);
Assert.Equal(new DateTime(2015, 04, 17, 14, 22, 17, DateTimeKind.Utc), lineupsDto.LineupTimestamp);
Assert.Equal(5, lineupsDto.Lineups.Count);
Assert.Equal("GBR-0001317-DEFAULT", lineupsDto.Lineups[0].Lineup);
Assert.Equal("Freeview - Carlton - LWT (Southeast)", lineupsDto.Lineups[0].Name);
Assert.Equal("DVB-T", lineupsDto.Lineups[0].Transport);
Assert.Equal("London", lineupsDto.Lineups[0].Location);
Assert.Equal("/20141201/lineups/GBR-0001317-DEFAULT", lineupsDto.Lineups[0].Uri);
Assert.Equal("DELETED LINEUP", lineupsDto.Lineups[4].Name);
Assert.True(lineupsDto.Lineups[4].IsDeleted);
}
/// <summary>
/// /lineup/:id response.
/// </summary>
[Fact]
public void Deserialize_Lineup_Response_Success()
{
var bytes = File.ReadAllBytes("Test Data/SchedulesDirect/lineup_response.json");
var channelDto = JsonSerializer.Deserialize<ChannelDto>(bytes, _jsonOptions);
Assert.NotNull(channelDto);
Assert.Equal(2, channelDto!.Map.Count);
Assert.Equal("24326", channelDto.Map[0].StationId);
Assert.Equal("001", channelDto.Map[0].Channel);
Assert.Equal("BBC ONE South", channelDto.Map[0].ProvderCallsign);
Assert.Equal("1", channelDto.Map[0].LogicalChannelNumber);
Assert.Equal("providerCallsign", channelDto.Map[0].MatchType);
}
}
}

View file

@ -0,0 +1 @@
[{"headend":"CA00053","transport":"Cable","location":"Beverly Hills","lineups":[{"name":"Time Warner Cable - Cable","lineup":"USA-CA00053-DEFAULT","uri":"/20141201/lineups/USA-CA00053-DEFAULT"},{"name":"Time Warner Cable - Digital","lineup":"USA-CA00053-X","uri":"/20141201/lineups/USA-CA00053-X"}]},{"headend":"CA61222","transport":"Cable","location":"Beverly Hills","lineups":[{"name":"Mulholland Estates - Cable","lineup":"USA-CA61222-DEFAULT","uri":"/20141201/lineups/USA-CA61222-DEFAULT"}]},{"headend":"CA66511","transport":"Cable","location":"Los Angeles","lineups":[{"name":"AT&T U-verse TV - Digital","lineup":"USA-CA66511-X","uri":"/20141201/lineups/USA-CA66511-X"}]},{"headend":"CA67309","transport":"Cable","location":"Westchester","lineups":[{"name":"Time Warner Cable Sherman Oaks - Cable","lineup":"USA-CA67309-DEFAULT","uri":"/20141201/lineups/USA-CA67309-DEFAULT"},{"name":"Time Warner Cable Sherman Oaks - Digital","lineup":"USA-CA67309-X","uri":"/20141201/lineups/USA-CA67309-X"}]},{"headend":"CA67310","transport":"Cable","location":"Eagle Rock","lineups":[{"name":"Time Warner Cable City of Los Angeles - Cable","lineup":"USA-CA67310-DEFAULT","uri":"/20141201/lineups/USA-CA67310-DEFAULT"},{"name":"Time Warner Cable City of Los Angeles - Digital","lineup":"USA-CA67310-X","uri":"/20141201/lineups/USA-CA67310-X"}]},{"headend":"DISH803","transport":"Satellite","location":"Los Angeles","lineups":[{"name":"DISH Los Angeles - Satellite","lineup":"USA-DISH803-DEFAULT","uri":"/20141201/lineups/USA-DISH803-DEFAULT"}]},{"headend":"DITV803","transport":"Satellite","location":"Los Angeles","lineups":[{"name":"DIRECTV Los Angeles - Satellite","lineup":"USA-DITV803-DEFAULT","uri":"/20141201/lineups/USA-DITV803-DEFAULT"}]},{"headend":"90210","transport":"Antenna","location":"90210","lineups":[{"name":"Antenna","lineup":"USA-OTA-90210","uri":"/20141201/lineups/USA-OTA-90210"}]}]

View file

@ -0,0 +1 @@
{"map":[{"stationID":"24326","channel":"001","providerCallsign":"BBC ONE South","logicalChannelNumber":"1","matchType":"providerCallsign"},{"stationID":"17154","channel":"002","providerCallsign":"BBC TWO","logicalChannelNumber":"2","matchType":"providerCallsign"}]}

View file

@ -0,0 +1 @@
{"code":0,"serverID":"20141201.web.1","datetime":"2015-04-17T14:22:17Z","lineups":[{"lineup":"GBR-0001317-DEFAULT","name":"Freeview - Carlton - LWT (Southeast)","transport":"DVB-T","location":"London","uri":"/20141201/lineups/GBR-0001317-DEFAULT"},{"lineup":"USA-IL57303-X","name":"Comcast Waukegan/Lake Forest Area - Digital","transport":"Cable","location":"Lake Forest","uri":"/20141201/lineups/USA-IL57303-X"},{"lineup":"USA-NY67791-X","name":"Verizon Fios Queens - Digital","transport":"Cable","location":"Fresh Meadows","uri":"/20141201/lineups/USA-NY67791-X"},{"lineup":"USA-OTA-60030","name":"Local Over the Air Broadcast","transport":"Antenna","location":"60030","uri":"/20141201/lineups/USA-OTA-60030"},{"lineup":"USA-WI61859-DEFAULT","name":"DELETED LINEUP","isDeleted":true}]}

View file

@ -0,0 +1 @@
[{"programID":"SH00712240","data":[{"width":"135","height":"180","uri":"assets/p282288_b_v2_aa.jpg","size":"Sm","aspect":"3x4","category":"Banner-L3","text":"yes","primary":"true","tier":"Series"},{"width":"720","height":"540","uri":"assets/p282288_b_h6_aa.jpg","size":"Lg","aspect":"4x3","category":"Banner-L3","text":"yes","primary":"true","tier":"Series"},{"width":"960","height":"1440","uri":"assets/p282288_b_v8_aa.jpg","size":"Ms","aspect":"2x3","category":"Banner-L3","text":"yes","primary":"true","tier":"Series"},{"width":"180","height":"135","uri":"assets/p282288_b_h5_aa.jpg","size":"Sm","aspect":"4x3","category":"Banner-L3","text":"yes","primary":"true","tier":"Series"}]}]

View file

@ -0,0 +1 @@
[{"programID":"EP000000060003","titles":[{"title120":"'Allo 'Allo!"}],"eventDetails":{"subType":"Series"},"descriptions":{"description1000":[{"descriptionLanguage":"en","description":"A disguised British Intelligence officer is sent to help the airmen."}]},"originalAirDate":"1985-11-04","genres":["Sitcom"],"episodeTitle150":"The Poloceman Cometh","metadata":[{"Gracenote":{"season":2,"episode":3}}],"cast":[{"personId":"383774","nameId":"392649","name":"Gorden Kaye","role":"Actor","billingOrder":"01"},{"personId":"246840","nameId":"250387","name":"Carmen Silvera","role":"Actor","billingOrder":"02"},{"personId":"376955","nameId":"385830","name":"Rose Hill","role":"Actor","billingOrder":"03"},{"personId":"259773","nameId":"263340","name":"Vicki Michelle","role":"Actor","billingOrder":"04"},{"personId":"353113","nameId":"361987","name":"Kirsten Cooke","role":"Actor","billingOrder":"05"},{"personId":"77787","nameId":"77787","name":"Richard Marner","role":"Actor","billingOrder":"06"},{"personId":"230921","nameId":"234193","name":"Guy Siner","role":"Actor","billingOrder":"07"},{"personId":"374934","nameId":"383809","name":"Kim Hartman","role":"Actor","billingOrder":"08"},{"personId":"369151","nameId":"378026","name":"Richard Gibson","role":"Actor","billingOrder":"09"},{"personId":"343690","nameId":"352564","name":"Arthur Bostrom","role":"Actor","billingOrder":"10"},{"personId":"352557","nameId":"361431","name":"John D. Collins","role":"Actor","billingOrder":"11"},{"personId":"605275","nameId":"627734","name":"Nicholas Frankau","role":"Actor","billingOrder":"12"},{"personId":"373394","nameId":"382269","name":"Jack Haig","role":"Actor","billingOrder":"13"}],"crew":[{"personId":"354407","nameId":"363281","name":"David Croft","role":"Director","billingOrder":"01"},{"personId":"354407","nameId":"363281","name":"David Croft","role":"Writer","billingOrder":"02"},{"personId":"105145","nameId":"105145","name":"Jeremy Lloyd","role":"Writer","billingOrder":"03"}],"showType":"Series","hasImageArtwork":true,"md5":"Jo5NKxoo44xRvBCAq8QT2A"},{"programID":"EP000000510142","titles":[{"title120":"A Different World"}],"eventDetails":{"subType":"Series"},"descriptions":{"description1000":[{"descriptionLanguage":"en","description":"Whitley and Dwayne tell new students about their honeymoon in Los Angeles."}]},"originalAirDate":"1992-09-24","genres":["Sitcom"],"episodeTitle150":"Honeymoon in L.A.","metadata":[{"Gracenote":{"season":6,"episode":1}}],"cast":[{"personId":"700","nameId":"700","name":"Jasmine Guy","role":"Actor","billingOrder":"01"},{"personId":"729","nameId":"729","name":"Kadeem Hardison","role":"Actor","billingOrder":"02"},{"personId":"120","nameId":"120","name":"Darryl M. Bell","role":"Actor","billingOrder":"03"},{"personId":"1729","nameId":"1729","name":"Cree Summer","role":"Actor","billingOrder":"04"},{"personId":"217","nameId":"217","name":"Charnele Brown","role":"Actor","billingOrder":"05"},{"personId":"1811","nameId":"1811","name":"Glynn Turman","role":"Actor","billingOrder":"06"},{"personId":"1232","nameId":"1232","name":"Lou Myers","role":"Actor","billingOrder":"07"},{"personId":"1363","nameId":"1363","name":"Jada Pinkett","role":"Guest Star","billingOrder":"08"},{"personId":"222967","nameId":"225536","name":"Ajai Sanders","role":"Guest Star","billingOrder":"09"},{"personId":"181744","nameId":"183292","name":"Karen Malina White","role":"Guest Star","billingOrder":"10"},{"personId":"305017","nameId":"318897","name":"Patrick Y. Malone","role":"Guest Star","billingOrder":"11"},{"personId":"9841","nameId":"9841","name":"Bumper Robinson","role":"Guest Star","billingOrder":"12"},{"personId":"426422","nameId":"435297","name":"Sister Souljah","role":"Guest Star","billingOrder":"13"},{"personId":"25","nameId":"25","name":"Debbie Allen","role":"Guest Star","billingOrder":"14"},{"personId":"668","nameId":"668","name":"Gilbert Gottfried","role":"Guest Star","billingOrder":"15"}],"showType":"Series","hasImageArtwork":true,"md5":"P5kz0QmCeYxIA+yL0H4DWw"}]

View file

@ -0,0 +1 @@
[{"stationID":"20454","date":["2015-03-13","2015-03-17"]},{"stationID":"10021","date":["2015-03-12","2015-03-13"]}]

View file

@ -0,0 +1 @@
[{"stationID":"20454","programs":[{"programID":"SH005371070000","airDateTime":"2015-03-03T00:00:00Z","duration":1800,"md5":"Sy8HEMBPcuiAx3FBukUhKQ","new":true,"audioProperties":["stereo","cc"],"videoProperties":["hdtv"]},{"programID":"EP000014577244","airDateTime":"2015-03-03T00:30:00Z","duration":1800,"md5":"25DNXVXO192JI7Y9vSW9lQ","new":true,"audioProperties":["stereo","cc"],"videoProperties":["hdtv"]}]}]

View file

@ -0,0 +1 @@
{"code":0,"message":"OK","serverID":"AWS-SD-web.1","datetime":"2016-08-23T13:55:25Z","token":"f3fca79989cafe7dead71beefedc812b"}

View file

@ -0,0 +1 @@
{"response":"SERVICE_OFFLINE","code":3000,"serverID":"20141201.web.1","message":"Server offline for maintenance.","datetime":"2015-04-23T00:03:32Z","token":"CAFEDEADBEEFCAFEDEADBEEFCAFEDEADBEEFCAFE"}