updated nuget

This commit is contained in:
Luke Pulverenti 2013-11-25 16:53:06 -05:00
parent a641059c57
commit 3b4c355838
6 changed files with 177 additions and 103 deletions

View File

@ -20,6 +20,12 @@ namespace MediaBrowser.Controller.LiveTv
/// </summary>
public string ChannelName { get; set; }
/// <summary>
/// Gets or sets the program identifier.
/// </summary>
/// <value>The program identifier.</value>
public string ProgramId { get; set; }
/// <summary>
/// Name of the recording.
/// </summary>
@ -46,14 +52,10 @@ namespace MediaBrowser.Controller.LiveTv
public string Status { get; set; } //TODO: Enum for status?? Difference NextPvr,Argus,...
/// <summary>
/// Quality of the Recording.
/// Gets or sets a value indicating whether this instance is recurring.
/// </summary>
public string Quality { get; set; } // TODO: Enum for quality?? Difference NextPvr,Argus,...
/// <summary>
/// Recurring recording?
/// </summary>
public bool Recurring { get; set; }
/// <value><c>true</c> if this instance is recurring; otherwise, <c>false</c>.</value>
public bool IsRecurring { get; set; }
/// <summary>
/// Parent recurring.

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.LiveTv
{
@ -10,6 +9,18 @@ namespace MediaBrowser.Model.LiveTv
/// </summary>
public string Id { get; set; }
/// <summary>
/// Gets or sets the external identifier.
/// </summary>
/// <value>The external identifier.</value>
public string ExternalId { get; set; }
/// <summary>
/// Gets or sets the program identifier.
/// </summary>
/// <value>The program identifier.</value>
public string ProgramId { get; set; }
/// <summary>
/// ChannelId of the recording.
/// </summary>
@ -41,38 +52,8 @@ namespace MediaBrowser.Model.LiveTv
public DateTime EndDate { get; set; }
/// <summary>
/// Status of the recording.
/// IsRecurring recording?
/// </summary>
public string Status { get; set; } //TODO: Enum for status?? Difference NextPvr,Argus,...
/// <summary>
/// Quality of the Recording.
/// </summary>
public string Quality { get; set; } // TODO: Enum for quality?? Difference NextPvr,Argus,...
/// <summary>
/// Recurring recording?
/// </summary>
public bool Recurring { get; set; }
/// <summary>
/// Parent recurring.
/// </summary>
public string RecurringParent { get; set; }
/// <summary>
/// Start date for the recurring, in UTC.
/// </summary>
public DateTime RecurrringStartDate { get; set; }
/// <summary>
/// End date for the recurring, in UTC
/// </summary>
public DateTime RecurringEndDate { get; set; }
/// <summary>
/// When do we need the recording?
/// </summary>
public List<string> DayMask { get; set; }
public bool IsRecurring { get; set; }
}
}

View File

@ -7,13 +7,13 @@ using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Querying;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.LiveTv
{
@ -32,6 +32,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private List<Channel> _channels = new List<Channel>();
private List<ProgramInfoDto> _programs = new List<ProgramInfoDto>();
private List<RecordingInfoDto> _recordings = new List<RecordingInfoDto>();
private readonly SemaphoreSlim _updateSemaphore = new SemaphoreSlim(1, 1);
public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor)
{
@ -137,62 +140,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return _channels.FirstOrDefault(i => i.Id == guid);
}
internal async Task RefreshChannels(IProgress<double> progress, CancellationToken cancellationToken)
{
// Avoid implicitly captured closure
var currentCancellationToken = cancellationToken;
var channelTasks = _services.Select(i => i.GetChannelsAsync(currentCancellationToken));
progress.Report(10);
var results = await Task.WhenAll(channelTasks).ConfigureAwait(false);
var allChannels = results.SelectMany(i => i).ToList();
var list = new List<Channel>();
var programs = new List<ProgramInfoDto>();
var numComplete = 0;
foreach (var channelInfo in allChannels)
{
try
{
var item = await GetChannel(channelInfo, cancellationToken).ConfigureAwait(false);
var service = GetService(channelInfo);
var channelPrograms = await service.GetProgramsAsync(channelInfo.Id, cancellationToken).ConfigureAwait(false);
programs.AddRange(channelPrograms.Select(program => GetProgramInfoDto(program, item)));
list.Add(item);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception ex)
{
_logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Name);
}
numComplete++;
double percent = numComplete;
percent /= allChannels.Count;
progress.Report(90 * percent + 10);
}
_programs = programs;
_channels = list;
}
private ProgramInfoDto GetProgramInfoDto(ProgramInfo program, Channel channel)
{
var id = channel.ServiceName + channel.ChannelId + program.Id;
id = id.GetMD5().ToString("N");
var id = GetInternalProgramIdId(channel.ServiceName, program.Id).ToString("N");
return new ProgramInfoDto
{
@ -208,6 +158,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv
};
}
private Guid GetInternalChannelId(string serviceName, string externalChannelId)
{
var name = serviceName + externalChannelId;
return name.ToLower().GetMBId(typeof(Channel));
}
private Guid GetInternalProgramIdId(string serviceName, string externalProgramId)
{
var name = serviceName + externalProgramId;
return name.ToLower().GetMD5();
}
private async Task<Channel> GetChannel(ChannelInfo channelInfo, CancellationToken cancellationToken)
{
var path = Path.Combine(_appPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.ServiceName), _fileSystem.GetValidFilename(channelInfo.Name));
@ -229,9 +193,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
isNew = true;
}
var type = typeof(Channel);
var id = (path + channelInfo.Number).GetMBId(type);
var id = GetInternalChannelId(channelInfo.ServiceName, channelInfo.Id);
var item = _itemRepo.RetrieveItem(id) as Channel;
@ -286,5 +248,134 @@ namespace MediaBrowser.Server.Implementations.LiveTv
TotalRecordCount = returnArray.Length
};
}
internal async Task RefreshChannels(IProgress<double> progress, CancellationToken cancellationToken)
{
await _updateSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
await RefreshChannelsInternal(progress, cancellationToken).ConfigureAwait(false);
}
finally
{
_updateSemaphore.Release();
}
await RefreshRecordings(new Progress<double>(), cancellationToken).ConfigureAwait(false);
}
private async Task RefreshChannelsInternal(IProgress<double> progress, CancellationToken cancellationToken)
{
// Avoid implicitly captured closure
var currentCancellationToken = cancellationToken;
var channelTasks = _services.Select(i => i.GetChannelsAsync(currentCancellationToken));
progress.Report(10);
var results = await Task.WhenAll(channelTasks).ConfigureAwait(false);
var allChannels = results.SelectMany(i => i).ToList();
var list = new List<Channel>();
var programs = new List<ProgramInfoDto>();
var numComplete = 0;
foreach (var channelInfo in allChannels)
{
try
{
var item = await GetChannel(channelInfo, cancellationToken).ConfigureAwait(false);
var service = GetService(channelInfo);
var channelPrograms = await service.GetProgramsAsync(channelInfo.Id, cancellationToken).ConfigureAwait(false);
programs.AddRange(channelPrograms.Select(program => GetProgramInfoDto(program, item)));
list.Add(item);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception ex)
{
_logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Name);
}
numComplete++;
double percent = numComplete;
percent /= allChannels.Count;
progress.Report(90 * percent + 10);
}
_programs = programs;
_channels = list;
}
internal async Task RefreshRecordings(IProgress<double> progress, CancellationToken cancellationToken)
{
await _updateSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
await RefreshRecordingsInternal(progress, cancellationToken).ConfigureAwait(false);
}
finally
{
_updateSemaphore.Release();
}
}
private async Task RefreshRecordingsInternal(IProgress<double> progress, CancellationToken cancellationToken)
{
var list = new List<RecordingInfoDto>();
foreach (var service in _services)
{
var recordings = await GetRecordings(service, cancellationToken).ConfigureAwait(false);
list.AddRange(recordings);
}
_recordings = list;
}
private async Task<IEnumerable<RecordingInfoDto>> GetRecordings(ILiveTvService service, CancellationToken cancellationToken)
{
var recordings = await service.GetRecordingsAsync(cancellationToken).ConfigureAwait(false);
return recordings.Select(i => GetRecordingInfoDto(i, service));
}
private RecordingInfoDto GetRecordingInfoDto(RecordingInfo info, ILiveTvService service)
{
var id = service.Name + info.ChannelId + info.Id;
id = id.GetMD5().ToString("N");
var dto = new RecordingInfoDto
{
ChannelName = info.ChannelName,
Description = info.Description,
EndDate = info.EndDate,
Name = info.Name,
IsRecurring = info.IsRecurring,
StartDate = info.StartDate,
Id = id,
ExternalId = info.Id,
ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N")
};
if (!string.IsNullOrEmpty(info.ProgramId))
{
dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N");
}
return dto;
}
}
}

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.248</version>
<version>3.0.249</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.248" />
<dependency id="MediaBrowser.Common" version="3.0.249" />
<dependency id="NLog" version="2.1.0" />
<dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.6" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.248</version>
<version>3.0.249</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.248</version>
<version>3.0.249</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.248" />
<dependency id="MediaBrowser.Common" version="3.0.249" />
</dependencies>
</metadata>
<files>