sync with master

pull/702/head
Luke Pulverenti 9 years ago
parent 82058128d6
commit 845bea9a64

@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
UserAgent = UserAgent,
CancellationToken = cancellationToken,
// The data can be large so give it some extra time
TimeoutMs = 60000,
TimeoutMs = 120000,
LogErrorResponseBody = true
};
@ -114,7 +114,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
var requestString = _jsonSerializer.SerializeToString(requestList);
_logger.Debug("Request string for schedules is: " + requestString);
httpOptions.RequestContent = requestString;
using (var response = await Post(httpOptions).ConfigureAwait(false))
using (var response = await _httpClient.Post(httpOptions))
{
StreamReader reader = new StreamReader(response.Content);
string responseString = reader.ReadToEnd();
@ -126,7 +126,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
Url = ApiUrl + "/programs",
UserAgent = UserAgent,
CancellationToken = cancellationToken,
LogErrorResponseBody = true
LogErrorResponseBody = true,
// The data can be large so give it some extra time
TimeoutMs = 60000
};
httpOptions.RequestHeaders["token"] = token;
@ -136,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
var requestBody = "[\"" + string.Join("\", \"", programsID) + "\"]";
httpOptions.RequestContent = requestBody;
using (var innerResponse = await Post(httpOptions).ConfigureAwait(false))
using (var innerResponse = await _httpClient.Post(httpOptions))
{
StreamReader innerReader = new StreamReader(innerResponse.Content);
responseString = innerReader.ReadToEnd();
@ -225,7 +227,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token;
using (var response = await Get(httpOptions).ConfigureAwait(false))
using (var response = await _httpClient.Get(httpOptions))
{
var root = _jsonSerializer.DeserializeFromStream<ScheduleDirect.Channel>(response);
_logger.Info("Found " + root.map.Count() + " channels on the lineup on ScheduleDirect");
@ -463,10 +465,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
UserAgent = UserAgent,
CancellationToken = cancellationToken,
RequestContent = imageIdString,
LogErrorResponseBody = true
LogErrorResponseBody = true,
// The data can be large so give it some extra time
TimeoutMs = 60000
};
List<ScheduleDirect.ShowImages> images;
using (var innerResponse2 = await Post(httpOptions).ConfigureAwait(false))
using (var innerResponse2 = await _httpClient.Post(httpOptions))
{
images = _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.ShowImages>>(
innerResponse2.Content);
@ -498,7 +502,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
try
{
using (Stream responce = await Get(options).ConfigureAwait(false))
using (Stream responce = await _httpClient.Get(options).ConfigureAwait(false))
{
var root = _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.Headends>>(responce);
@ -567,7 +571,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
if (long.TryParse(savedToken.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out ticks))
{
// If it's under 24 hours old we can still use it
if ((DateTime.UtcNow.Ticks - ticks) < TimeSpan.FromHours(20).Ticks)
if ((DateTime.UtcNow.Ticks - ticks) < TimeSpan.FromHours(24).Ticks)
{
return savedToken.Name;
}
@ -600,32 +604,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
}
}
private async Task<HttpResponseInfo> Post(HttpRequestOptions options)
{
try
{
return await _httpClient.Post(options).ConfigureAwait(false);
}
catch
{
_tokens.Clear();
throw;
}
}
private async Task<Stream> Get(HttpRequestOptions options)
{
try
{
return await _httpClient.Get(options).ConfigureAwait(false);
}
catch
{
_tokens.Clear();
throw;
}
}
private async Task<string> GetTokenInternal(string username, string password,
CancellationToken cancellationToken)
{
@ -640,7 +618,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
//_logger.Info("Obtaining token from Schedules Direct from addres: " + httpOptions.Url + " with body " +
// httpOptions.RequestContent);
using (var responce = await Post(httpOptions).ConfigureAwait(false))
using (var responce = await _httpClient.Post(httpOptions))
{
var root = _jsonSerializer.DeserializeFromStream<ScheduleDirect.Token>(responce.Content);
if (root.message == "OK")
@ -722,7 +700,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
try
{
using (var response = await Get(options).ConfigureAwait(false))
using (var response = await _httpClient.Get(options).ConfigureAwait(false))
{
var root = _jsonSerializer.DeserializeFromStream<ScheduleDirect.Lineups>(response);

@ -134,7 +134,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var items = await RetrieveItems(CancellationToken.None).ConfigureAwait(false);
items = action(items);
await SaveData(items.ToList(), CancellationToken.None).ConfigureAwait(false);
await UpdateCache(null).ConfigureAwait(false);
}

Loading…
Cancel
Save