aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-25 16:53:06 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-25 16:53:06 -0500
commit3b4c35583808a84af2ee636a00fea8355e645b2e (patch)
tree4c78b12660e5ab1fde16d64f3e7cb0c2314b677f
parenta641059c571d9596baa814a01a85546e3a4b5b50 (diff)
updated nuget
-rw-r--r--MediaBrowser.Controller/LiveTv/RecordingInfo.cs16
-rw-r--r--MediaBrowser.Model/LiveTv/RecordingInfoDto.cs47
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs207
-rw-r--r--Nuget/MediaBrowser.Common.Internal.nuspec4
-rw-r--r--Nuget/MediaBrowser.Common.nuspec2
-rw-r--r--Nuget/MediaBrowser.Server.Core.nuspec4
6 files changed, 177 insertions, 103 deletions
diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
index f35b6d5c6..0e4be52e3 100644
--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
@@ -21,6 +21,12 @@ namespace MediaBrowser.Controller.LiveTv
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>
public string Name { get; set; }
@@ -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.
- /// </summary>
- public string Quality { get; set; } // TODO: Enum for quality?? Difference NextPvr,Argus,...
-
- /// <summary>
- /// Recurring recording?
+ /// Gets or sets a value indicating whether this instance is recurring.
/// </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.
diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
index b24af04a0..782652f37 100644
--- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
+++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
namespace MediaBrowser.Model.LiveTv
{
@@ -11,6 +10,18 @@ namespace MediaBrowser.Model.LiveTv
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>
public string ChannelId { get; set; }
@@ -41,38 +52,8 @@ namespace MediaBrowser.Model.LiveTv
public DateTime EndDate { get; set; }
/// <summary>
- /// Status of the 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?
+ /// IsRecurring recording?
/// </summary>
- public List<string> DayMask { get; set; }
+ public bool IsRecurring { get; set; }
}
} \ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index fe58f292c..791da74e0 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -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;
+ }
}
}
diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec
index 5a32ce2dd..f0c2c4308 100644
--- a/Nuget/MediaBrowser.Common.Internal.nuspec
+++ b/Nuget/MediaBrowser.Common.Internal.nuspec
@@ -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" />
diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec
index e363cf621..ff211ee1b 100644
--- a/Nuget/MediaBrowser.Common.nuspec
+++ b/Nuget/MediaBrowser.Common.nuspec
@@ -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>
diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec
index 83861329b..25198e155 100644
--- a/Nuget/MediaBrowser.Server.Core.nuspec
+++ b/Nuget/MediaBrowser.Server.Core.nuspec
@@ -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>