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