|
@@ -41,6 +41,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
/// </summary>
|
|
|
public class LiveTvManager : ILiveTvManager, IDisposable
|
|
|
{
|
|
|
+ private const int MaxGuideDays = 14;
|
|
|
private const string ExternalServiceTag = "ExternalServiceId";
|
|
|
|
|
|
private const string EtagKey = "ProgramEtag";
|
|
@@ -560,7 +561,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
item.Audio = info.Audio;
|
|
|
item.ChannelId = channel.Id;
|
|
|
- item.CommunityRating = item.CommunityRating ?? info.CommunityRating;
|
|
|
+ item.CommunityRating ??= info.CommunityRating;
|
|
|
if ((item.CommunityRating ?? 0).Equals(0))
|
|
|
{
|
|
|
item.CommunityRating = null;
|
|
@@ -645,8 +646,8 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
item.IsSeries = isSeries;
|
|
|
|
|
|
item.Name = info.Name;
|
|
|
- item.OfficialRating = item.OfficialRating ?? info.OfficialRating;
|
|
|
- item.Overview = item.Overview ?? info.Overview;
|
|
|
+ item.OfficialRating ??= info.OfficialRating;
|
|
|
+ item.Overview ??= info.Overview;
|
|
|
item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
|
|
|
item.ProviderIds = info.ProviderIds;
|
|
|
|
|
@@ -683,19 +684,23 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(info.ImagePath))
|
|
|
{
|
|
|
- item.SetImage(new ItemImageInfo
|
|
|
- {
|
|
|
- Path = info.ImagePath,
|
|
|
- Type = ImageType.Primary
|
|
|
- }, 0);
|
|
|
+ item.SetImage(
|
|
|
+ new ItemImageInfo
|
|
|
+ {
|
|
|
+ Path = info.ImagePath,
|
|
|
+ Type = ImageType.Primary
|
|
|
+ },
|
|
|
+ 0);
|
|
|
}
|
|
|
else if (!string.IsNullOrWhiteSpace(info.ImageUrl))
|
|
|
{
|
|
|
- item.SetImage(new ItemImageInfo
|
|
|
- {
|
|
|
- Path = info.ImageUrl,
|
|
|
- Type = ImageType.Primary
|
|
|
- }, 0);
|
|
|
+ item.SetImage(
|
|
|
+ new ItemImageInfo
|
|
|
+ {
|
|
|
+ Path = info.ImageUrl,
|
|
|
+ Type = ImageType.Primary
|
|
|
+ },
|
|
|
+ 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -703,11 +708,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(info.ThumbImageUrl))
|
|
|
{
|
|
|
- item.SetImage(new ItemImageInfo
|
|
|
- {
|
|
|
- Path = info.ThumbImageUrl,
|
|
|
- Type = ImageType.Thumb
|
|
|
- }, 0);
|
|
|
+ item.SetImage(
|
|
|
+ new ItemImageInfo
|
|
|
+ {
|
|
|
+ Path = info.ThumbImageUrl,
|
|
|
+ Type = ImageType.Thumb
|
|
|
+ },
|
|
|
+ 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -715,11 +722,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(info.LogoImageUrl))
|
|
|
{
|
|
|
- item.SetImage(new ItemImageInfo
|
|
|
- {
|
|
|
- Path = info.LogoImageUrl,
|
|
|
- Type = ImageType.Logo
|
|
|
- }, 0);
|
|
|
+ item.SetImage(
|
|
|
+ new ItemImageInfo
|
|
|
+ {
|
|
|
+ Path = info.LogoImageUrl,
|
|
|
+ Type = ImageType.Logo
|
|
|
+ },
|
|
|
+ 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -727,11 +736,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(info.BackdropImageUrl))
|
|
|
{
|
|
|
- item.SetImage(new ItemImageInfo
|
|
|
- {
|
|
|
- Path = info.BackdropImageUrl,
|
|
|
- Type = ImageType.Backdrop
|
|
|
- }, 0);
|
|
|
+ item.SetImage(
|
|
|
+ new ItemImageInfo
|
|
|
+ {
|
|
|
+ Path = info.BackdropImageUrl,
|
|
|
+ Type = ImageType.Backdrop
|
|
|
+ },
|
|
|
+ 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -786,7 +797,6 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
if (query.OrderBy.Count == 0)
|
|
|
{
|
|
|
-
|
|
|
// Unless something else was specified, order by start date to take advantage of a specialized index
|
|
|
query.OrderBy = new[]
|
|
|
{
|
|
@@ -824,7 +834,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(query.SeriesTimerId))
|
|
|
{
|
|
|
- var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery { }, cancellationToken).ConfigureAwait(false);
|
|
|
+ var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false);
|
|
|
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
|
|
|
if (seriesTimer != null)
|
|
|
{
|
|
@@ -847,13 +857,11 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
var returnArray = _dtoService.GetBaseItemDtos(queryResult.Items, options, user);
|
|
|
|
|
|
- var result = new QueryResult<BaseItemDto>
|
|
|
+ return new QueryResult<BaseItemDto>
|
|
|
{
|
|
|
Items = returnArray,
|
|
|
TotalRecordCount = queryResult.TotalRecordCount
|
|
|
};
|
|
|
-
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
public QueryResult<BaseItem> GetRecommendedProgramsInternal(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken)
|
|
@@ -1173,7 +1181,6 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery
|
|
|
{
|
|
|
-
|
|
|
IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name },
|
|
|
ChannelIds = new Guid[] { currentChannel.Id },
|
|
|
DtoOptions = new DtoOptions(true)
|
|
@@ -1298,8 +1305,6 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private const int MaxGuideDays = 14;
|
|
|
-
|
|
|
private double GetGuideDays()
|
|
|
{
|
|
|
var config = GetConfiguration();
|
|
@@ -1712,7 +1717,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
if (timer == null)
|
|
|
{
|
|
|
- throw new ResourceNotFoundException(string.Format("Timer with Id {0} not found", id));
|
|
|
+ throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "Timer with Id {0} not found", id));
|
|
|
}
|
|
|
|
|
|
var service = GetService(timer.ServiceName);
|
|
@@ -1731,7 +1736,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
if (timer == null)
|
|
|
{
|
|
|
- throw new ResourceNotFoundException(string.Format("SeriesTimer with Id {0} not found", id));
|
|
|
+ throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "SeriesTimer with Id {0} not found", id));
|
|
|
}
|
|
|
|
|
|
var service = GetService(timer.ServiceName);
|
|
@@ -1743,10 +1748,12 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
public async Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var results = await GetTimers(new TimerQuery
|
|
|
- {
|
|
|
- Id = id
|
|
|
- }, cancellationToken).ConfigureAwait(false);
|
|
|
+ var results = await GetTimers(
|
|
|
+ new TimerQuery
|
|
|
+ {
|
|
|
+ Id = id
|
|
|
+ },
|
|
|
+ cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase));
|
|
|
}
|
|
@@ -1794,10 +1801,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
}
|
|
|
|
|
|
var returnArray = timers
|
|
|
- .Select(i =>
|
|
|
- {
|
|
|
- return i.Item1;
|
|
|
- })
|
|
|
+ .Select(i => i.Item1)
|
|
|
.ToArray();
|
|
|
|
|
|
return new QueryResult<SeriesTimerInfo>
|
|
@@ -1968,7 +1972,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
|
|
|
if (service == null)
|
|
|
{
|
|
|
- service = _services.First();
|
|
|
+ service = _services[0];
|
|
|
}
|
|
|
|
|
|
var info = await service.GetNewTimerDefaultsAsync(cancellationToken, programInfo).ConfigureAwait(false);
|
|
@@ -1994,9 +1998,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
{
|
|
|
var info = await GetNewTimerDefaultsInternal(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
- var obj = _tvDtoService.GetSeriesTimerInfoDto(info.Item1, info.Item2, null);
|
|
|
-
|
|
|
- return obj;
|
|
|
+ return _tvDtoService.GetSeriesTimerInfoDto(info.Item1, info.Item2, null);
|
|
|
}
|
|
|
|
|
|
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(string programId, CancellationToken cancellationToken)
|
|
@@ -2125,6 +2127,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
public void Dispose()
|
|
|
{
|
|
|
Dispose(true);
|
|
|
+ GC.SuppressFinalize(this);
|
|
|
}
|
|
|
|
|
|
private bool _disposed = false;
|
|
@@ -2447,8 +2450,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|
|
.SelectMany(i => i.Locations)
|
|
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
|
.Select(i => _libraryManager.FindByPath(i, true))
|
|
|
- .Where(i => i != null)
|
|
|
- .Where(i => i.IsVisibleStandalone(user))
|
|
|
+ .Where(i => i != null && i.IsVisibleStandalone(user))
|
|
|
.SelectMany(i => _libraryManager.GetCollectionFolders(i))
|
|
|
.GroupBy(x => x.Id)
|
|
|
.Select(x => x.First())
|