aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-29 16:31:15 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-29 16:31:15 -0400
commit8f75454d76c9c21018476fd278f91ae69f9268c0 (patch)
tree34a873aaf8ffd7420ca77a6f2e052a5d3dc30c75 /MediaBrowser.Server.Implementations/LiveTv
parent1f6b5a8c7c049bea309351dd495d99ec21eb32cb (diff)
update image processing
Diffstat (limited to 'MediaBrowser.Server.Implementations/LiveTv')
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs15
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs13
2 files changed, 19 insertions, 9 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 2319a6c2ca..c323f8e0dc 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common;
+using System.Globalization;
+using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
@@ -453,11 +454,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
- var duration = (timer.EndDate - DateTime.UtcNow).TotalSeconds + timer.PostPaddingSeconds;
+ var duration = (timer.EndDate - DateTime.UtcNow).Add(TimeSpan.FromSeconds(timer.PostPaddingSeconds));
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
{
- Url = mediaStreamInfo.Path + "?duration=" + duration
+ Url = mediaStreamInfo.Path + "?duration=" + duration.TotalSeconds.ToString(CultureInfo.InvariantCulture)
};
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
@@ -516,13 +517,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try
{
httpRequestOptions.BufferContent = false;
- httpRequestOptions.CancellationToken = cancellationToken;
+ var durationToken = new CancellationTokenSource(duration);
+ var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
+ httpRequestOptions.CancellationToken = linkedToken;
_logger.Info("Writing file to path: " + recordPath);
using (var response = await _httpClient.SendAsync(httpRequestOptions, "GET"))
{
using (var output = File.Open(recordPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
- await response.Content.CopyToAsync(output, 4096, cancellationToken);
+ await response.Content.CopyToAsync(output, 4096, linkedToken);
}
}
@@ -530,7 +533,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
catch (OperationCanceledException)
{
- recording.Status = RecordingStatus.Cancelled;
+ recording.Status = RecordingStatus.Completed;
}
catch
{
diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index ffafe59795..655feedae3 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.LiveTv;
@@ -20,19 +21,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
private readonly ILogger _logger;
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
- private const string UserAgent = "EmbyTV";
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
+ private readonly IApplicationHost _appHost;
private const string ApiUrl = "https://json.schedulesdirect.org/20141201";
private readonly ConcurrentDictionary<string, ScheduleDirect.Station> _channelPair =
new ConcurrentDictionary<string, ScheduleDirect.Station>();
- public SchedulesDirect(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public SchedulesDirect(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IApplicationHost appHost)
{
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
+ _appHost = appHost;
+ }
+
+ private string UserAgent
+ {
+ get { return "Emby/" + _appHost.ApplicationVersion; }
}
private List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)